IDEMPIERE-4227 Unable to use 2 print format item with the same AD_Column_ID and different formatting (#740)

* IDEMPIERE-4227 Unable to use 2 print format item with the same AD_Column_ID and different formatting

Fix function column
This commit is contained in:
hengsin 2021-06-28 19:47:20 +08:00 committed by GitHub
parent 0bfeb8c0b0
commit df704cb236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 242 additions and 210 deletions

View File

@ -100,15 +100,13 @@ extends AbstractExcelExporter
Object obj = null; Object obj = null;
if (item.isTypeField() || item.isTypePrintFormat() && item.isImageField()) { if (item.isTypeField() || item.isTypePrintFormat() && item.isImageField()) {
int AD_Column_ID = item.getAD_Column_ID(); obj = m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
if (AD_Column_ID > 0)
obj = m_printData.getNode(Integer.valueOf(AD_Column_ID));
} }
/** DEVCOFFEE: script column **/ /** DEVCOFFEE: script column **/
if (item.isTypeScript()) if (item.isTypeScript())
{ {
obj = m_printData.getNode(item.getName()); obj = m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
} }
if (obj != null && obj instanceof PrintDataElement) { if (obj != null && obj instanceof PrintDataElement) {

View File

@ -103,15 +103,13 @@ public class PrintDataXLSXExporter extends AbstractXLSXExporter
if (item.isTypeField() || item.isTypePrintFormat() && item.isImageField()) if (item.isTypeField() || item.isTypePrintFormat() && item.isImageField())
{ {
int AD_Column_ID = item.getAD_Column_ID(); obj = m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
if (AD_Column_ID > 0)
obj = m_printData.getNode(Integer.valueOf(AD_Column_ID));
} }
/** DEVCOFFEE: script column **/ /** DEVCOFFEE: script column **/
if (item.isTypeScript()) if (item.isTypeScript())
{ {
obj = m_printData.getNode(item.getName()); obj = m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
} }
if (obj != null && obj instanceof PrintDataElement) if (obj != null && obj instanceof PrintDataElement)

View File

@ -280,7 +280,7 @@ public class DataEngine
.append("c.ColumnSQL, COALESCE(pfi.FormatPattern, c.FormatPattern) ") // 24, 25 .append("c.ColumnSQL, COALESCE(pfi.FormatPattern, c.FormatPattern) ") // 24, 25
//BEGIN http://jira.idempiere.com/browse/IDEMPIERE-153 //BEGIN http://jira.idempiere.com/browse/IDEMPIERE-153
/** START DEVCOFFEE: script column **/ /** START DEVCOFFEE: script column **/
.append(" , pfi.isDesc, pfi.Script, pfi.Name ") // 26..28 .append(" , pfi.isDesc, pfi.Script, pfi.Name, pfi.AD_PrintFormatItem_ID ") // 26..29
//END //END
.append("FROM AD_PrintFormat pf") .append("FROM AD_PrintFormat pf")
.append(" INNER JOIN AD_PrintFormatItem pfi ON (pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID)") .append(" INNER JOIN AD_PrintFormatItem pfi ON (pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID)")
@ -322,6 +322,7 @@ public class DataEngine
{ {
// get Values from record // get Values from record
int AD_Column_ID = rs.getInt(1); int AD_Column_ID = rs.getInt(1);
int AD_PrintFormatItem_ID = rs.getInt("AD_PrintFormatItem_ID");
String ColumnName = rs.getString(2); String ColumnName = rs.getString(2);
String ColumnSQL = rs.getString(24); String ColumnSQL = rs.getString(24);
if (ColumnSQL != null && ColumnSQL.length() > 0 && ColumnSQL.startsWith("@SQLFIND=")) if (ColumnSQL != null && ColumnSQL.length() > 0 && ColumnSQL.startsWith("@SQLFIND="))
@ -354,21 +355,21 @@ public class DataEngine
FunctionColumn = ""; FunctionColumn = "";
// Breaks/Column Functions // Breaks/Column Functions
if ("Y".equals(rs.getString(11))) if ("Y".equals(rs.getString(11)))
m_group.addGroupColumn(ColumnName); m_group.addGroupColumn(AD_PrintFormatItem_ID);
if ("Y".equals(rs.getString(12))) if ("Y".equals(rs.getString(12)))
m_group.addFunction(ColumnName, PrintDataFunction.F_SUM); m_group.addFunction(AD_PrintFormatItem_ID, PrintDataFunction.F_SUM);
if ("Y".equals(rs.getString(13))) if ("Y".equals(rs.getString(13)))
m_group.addFunction(ColumnName, PrintDataFunction.F_MEAN); m_group.addFunction(AD_PrintFormatItem_ID, PrintDataFunction.F_MEAN);
if ("Y".equals(rs.getString(14))) if ("Y".equals(rs.getString(14)))
m_group.addFunction(ColumnName, PrintDataFunction.F_COUNT); m_group.addFunction(AD_PrintFormatItem_ID, PrintDataFunction.F_COUNT);
if ("Y".equals(rs.getString(18))) // IsMinCalc if ("Y".equals(rs.getString(18))) // IsMinCalc
m_group.addFunction(ColumnName, PrintDataFunction.F_MIN); m_group.addFunction(AD_PrintFormatItem_ID, PrintDataFunction.F_MIN);
if ("Y".equals(rs.getString(19))) // IsMaxCalc if ("Y".equals(rs.getString(19))) // IsMaxCalc
m_group.addFunction(ColumnName, PrintDataFunction.F_MAX); m_group.addFunction(AD_PrintFormatItem_ID, PrintDataFunction.F_MAX);
if ("Y".equals(rs.getString(22))) // IsVarianceCalc if ("Y".equals(rs.getString(22))) // IsVarianceCalc
m_group.addFunction(ColumnName, PrintDataFunction.F_VARIANCE); m_group.addFunction(AD_PrintFormatItem_ID, PrintDataFunction.F_VARIANCE);
if ("Y".equals(rs.getString(23))) // IsDeviationCalc if ("Y".equals(rs.getString(23))) // IsDeviationCalc
m_group.addFunction(ColumnName, PrintDataFunction.F_DEVIATION); m_group.addFunction(AD_PrintFormatItem_ID, PrintDataFunction.F_DEVIATION);
if ("Y".equals(rs.getString(20))) // isRunningTotal if ("Y".equals(rs.getString(20))) // isRunningTotal
// RunningTotalLines only once - use max // RunningTotalLines only once - use max
m_runningTotalLines = Math.max(m_runningTotalLines, rs.getInt(21)); m_runningTotalLines = Math.max(m_runningTotalLines, rs.getInt(21));
@ -399,7 +400,7 @@ public class DataEngine
// => Table.Column, // => Table.Column,
sqlSELECT.append(tableName).append(".").append(ColumnName).append(","); sqlSELECT.append(tableName).append(".").append(ColumnName).append(",");
groupByColumns.add(tableName+"."+ColumnName); groupByColumns.add(tableName+"."+ColumnName);
pdc = new PrintDataColumn(AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, KEY, isPageBreak); // KeyColumn pdc = new PrintDataColumn(AD_PrintFormatItem_ID, AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, KEY, isPageBreak); // KeyColumn
} }
/** START DEVCOFFEE: script column **/ /** START DEVCOFFEE: script column **/
else if (ColumnName == null || script != null && !script.isEmpty()) else if (ColumnName == null || script != null && !script.isEmpty())
@ -424,7 +425,7 @@ public class DataEngine
sqlSELECT.append(script).append(" AS \"").append(m_synonym).append(pfiName).append("\",") sqlSELECT.append(script).append(" AS \"").append(m_synonym).append(pfiName).append("\",")
.append("''").append(" AS \"").append(pfiName).append("\","); .append("''").append(" AS \"").append(pfiName).append("\",");
// //
pdc = new PrintDataColumn(-1, pfiName, DisplayType.Text, FieldLength, orderName, isPageBreak); pdc = new PrintDataColumn(AD_PrintFormatItem_ID, -1, pfiName, DisplayType.Text, FieldLength, orderName, isPageBreak);
synonymNext(); synonymNext();
} }
// -- Parent, TableDir (and unqualified Search) -- // -- Parent, TableDir (and unqualified Search) --
@ -459,7 +460,7 @@ public class DataEngine
groupByColumns.add(lookupSQL); groupByColumns.add(lookupSQL);
orderName = m_synonym + display; orderName = m_synonym + display;
// //
pdc = new PrintDataColumn(AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, orderName, isPageBreak); pdc = new PrintDataColumn(AD_PrintFormatItem_ID, AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, orderName, isPageBreak);
synonymNext(); synonymNext();
} }
@ -488,7 +489,7 @@ public class DataEngine
// //
TableReference tr = getTableReference(AD_Reference_Value_ID); TableReference tr = getTableReference(AD_Reference_Value_ID);
String foreignColumnName = tr.KeyColumn; String foreignColumnName = tr.KeyColumn;
pdc = new PrintDataColumn(AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, orderName, isPageBreak, foreignColumnName); pdc = new PrintDataColumn(AD_PrintFormatItem_ID, AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, orderName, isPageBreak, foreignColumnName);
synonymNext(); synonymNext();
} }
@ -533,7 +534,7 @@ public class DataEngine
} }
// TableName.ColumnName, // TableName.ColumnName,
sqlSELECT.append(lookupSQL).append(" AS ").append(ColumnName).append(","); sqlSELECT.append(lookupSQL).append(" AS ").append(ColumnName).append(",");
pdc = new PrintDataColumn(AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, orderName, isPageBreak); pdc = new PrintDataColumn(AD_PrintFormatItem_ID, AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, orderName, isPageBreak);
synonymNext(); synonymNext();
} }
@ -601,7 +602,7 @@ public class DataEngine
.append(lookupSQL).append("=") .append(lookupSQL).append("=")
.append(m_synonym).append(".").append(key).append(")"); .append(m_synonym).append(".").append(key).append(")");
// //
pdc = new PrintDataColumn(AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, orderName, isPageBreak); pdc = new PrintDataColumn(AD_PrintFormatItem_ID, AD_Column_ID, ColumnName, AD_Reference_ID, FieldLength, orderName, isPageBreak);
synonymNext(); synonymNext();
} }
@ -638,7 +639,7 @@ public class DataEngine
groupByColumns.add(sb.toString()); groupByColumns.add(sb.toString());
orderName = ColumnName; // no prefix for synonym orderName = ColumnName; // no prefix for synonym
} }
pdc = new PrintDataColumn(AD_Column_ID, ColumnName, pdc = new PrintDataColumn(AD_PrintFormatItem_ID, AD_Column_ID, ColumnName,
AD_Reference_ID, FieldLength, ColumnName, isPageBreak); AD_Reference_ID, FieldLength, ColumnName, isPageBreak);
} }
@ -925,11 +926,11 @@ public class DataEngine
for (int i = 0; i < pd.getColumnInfo().length; i++) for (int i = 0; i < pd.getColumnInfo().length; i++)
{ {
PrintDataColumn group_pdc = pd.getColumnInfo()[i]; PrintDataColumn group_pdc = pd.getColumnInfo()[i];
if (!m_group.isGroupColumn(group_pdc.getColumnName())) if (!m_group.isGroupColumn(group_pdc.getAD_PrintFormatItem_ID()))
continue; continue;
// Group change // Group change
Object value = m_group.groupChange(group_pdc.getColumnName(), rs.getObject(group_pdc.getAlias()), force); Object value = m_group.groupChange(group_pdc.getAD_PrintFormatItem_ID(), rs.getObject(group_pdc.getAlias()), force);
if (value != null) // Group change if (value != null) // Group change
{ {
changedGroups.add(group_pdc); changedGroups.add(group_pdc);
@ -943,7 +944,7 @@ public class DataEngine
PrintDataColumn group_pdc = changedGroups.get(j); PrintDataColumn group_pdc = changedGroups.get(j);
Object value = changedValues.get(j); Object value = changedValues.get(j);
char[] functions = m_group.getFunctions(group_pdc.getColumnName()); char[] functions = m_group.getFunctions(group_pdc.getAD_PrintFormatItem_ID());
for (int f = 0; f < functions.length; f++) for (int f = 0; f < functions.length; f++)
{ {
printRunningTotal(pd, levelNo, rowNo++); printRunningTotal(pd, levelNo, rowNo++);
@ -954,21 +955,21 @@ public class DataEngine
pdc = pd.getColumnInfo()[c]; pdc = pd.getColumnInfo()[c];
// log.fine("loadPrintData - PageBreak = " + pdc.isPageBreak()); // log.fine("loadPrintData - PageBreak = " + pdc.isPageBreak());
if (group_pdc.getColumnName().equals(pdc.getColumnName())) if (group_pdc.getAD_PrintFormatItem_ID() == pdc.getAD_PrintFormatItem_ID())
{ {
String valueString = value.toString(); String valueString = value.toString();
if (value instanceof Timestamp) if (value instanceof Timestamp)
valueString = DisplayType.getDateFormat(pdc.getDisplayType(), m_language).format(value); valueString = DisplayType.getDateFormat(pdc.getDisplayType(), m_language).format(value);
if (format.getTableFormat().isPrintFunctionSymbols()) // Translate Sum, etc. if (format.getTableFormat().isPrintFunctionSymbols()) // Translate Sum, etc.
valueString += PrintDataFunction.getFunctionSymbol(functions[f]); valueString += PrintDataFunction.getFunctionSymbol(functions[f]);
pd.addNode(new PrintDataElement(pdc.getColumnName(), pd.addNode(new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(),
valueString, DisplayType.String, false, pdc.isPageBreak(), pdc.getFormatPattern())); valueString, DisplayType.String, false, pdc.isPageBreak(), pdc.getFormatPattern()));
} }
else if (m_group.isFunctionColumn(pdc.getColumnName(), functions[f])) else if (m_group.isFunctionColumn(pdc.getAD_PrintFormatItem_ID(), functions[f]))
{ {
pd.addNode(new PrintDataElement(pdc.getColumnName(), pd.addNode(new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(),
m_group.getValue(group_pdc.getColumnName(), m_group.getValue(group_pdc.getAD_PrintFormatItem_ID(),
pdc.getColumnName(), functions[f]), pdc.getAD_PrintFormatItem_ID(), functions[f]),
PrintDataFunction.getFunctionDisplayType(functions[f], pdc.getDisplayType()), PrintDataFunction.getFunctionDisplayType(functions[f], pdc.getDisplayType()),
false, pdc.isPageBreak(), pdc.getFormatPattern())); false, pdc.isPageBreak(), pdc.getFormatPattern()));
} }
@ -978,7 +979,7 @@ public class DataEngine
for (int c = 0; c < pd.getColumnInfo().length; c++) for (int c = 0; c < pd.getColumnInfo().length; c++)
{ {
pdc = pd.getColumnInfo()[c]; pdc = pd.getColumnInfo()[c];
m_group.reset(group_pdc.getColumnName(), pdc.getColumnName()); m_group.reset(group_pdc.getAD_PrintFormatItem_ID(), pdc.getAD_PrintFormatItem_ID());
} }
} // Group change } // Group change
} // group change } // group change
@ -1006,7 +1007,7 @@ public class DataEngine
if (!rs.wasNull()) if (!rs.wasNull())
{ {
KeyNamePair pp = new KeyNamePair(id, KEY); // Key KeyNamePair pp = new KeyNamePair(id, KEY); // Key
pde = new PrintDataElement(pdc.getColumnName(), pp, pdc.getDisplayType(), pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), pp, pdc.getDisplayType(),
true, pdc.isPageBreak(), pdc.getFormatPattern()); true, pdc.isPageBreak(), pdc.getFormatPattern());
} }
} }
@ -1017,7 +1018,7 @@ public class DataEngine
if (!rs.wasNull()) if (!rs.wasNull())
{ {
ValueNamePair pp = new ValueNamePair(id, KEY); // Key ValueNamePair pp = new ValueNamePair(id, KEY); // Key
pde = new PrintDataElement(pdc.getColumnName(), pp, pdc.getDisplayType(), pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), pp, pdc.getDisplayType(),
true, pdc.isPageBreak(), pdc.getFormatPattern()); true, pdc.isPageBreak(), pdc.getFormatPattern());
} }
} }
@ -1036,7 +1037,7 @@ public class DataEngine
if (display != null && !rs.wasNull()) if (display != null && !rs.wasNull())
{ {
KeyNamePair pp = new KeyNamePair(id, display); KeyNamePair pp = new KeyNamePair(id, display);
pde = new PrintDataElement(pdc.getColumnName(), pp, pdc.getDisplayType(), pdc.getFormatPattern(), pdc.getForeignColumnName()); pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), pp, pdc.getDisplayType(), pdc.getFormatPattern(), pdc.getForeignColumnName());
} }
} }
else else
@ -1060,7 +1061,7 @@ public class DataEngine
} }
ValueNamePair pp = new ValueNamePair(id, display); ValueNamePair pp = new ValueNamePair(id, display);
pde = new PrintDataElement(pdc.getColumnName(), pp, displayType, pdc.getFormatPattern()); pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), pp, displayType, pdc.getFormatPattern());
} }
} }
} }
@ -1074,7 +1075,7 @@ public class DataEngine
if (!rs.wasNull()) if (!rs.wasNull())
{ {
boolean b = s.equals("Y"); boolean b = s.equals("Y");
pde = new PrintDataElement(pdc.getColumnName(), Boolean.valueOf(b), pdc.getDisplayType(), pdc.getFormatPattern()); pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), Boolean.valueOf(b), pdc.getDisplayType(), pdc.getFormatPattern());
} }
} }
else if (pdc.getDisplayType() == DisplayType.TextLong) else if (pdc.getDisplayType() == DisplayType.TextLong)
@ -1093,13 +1094,13 @@ public class DataEngine
value = clob.getSubString(1, (int)length); value = clob.getSubString(1, (int)length);
} }
} }
pde = new PrintDataElement(pdc.getColumnName(), value, pdc.getDisplayType(), pdc.getFormatPattern()); pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), value, pdc.getDisplayType(), pdc.getFormatPattern());
} }
// fix bug [ 1755592 ] Printing time in format // fix bug [ 1755592 ] Printing time in format
else if (pdc.getDisplayType() == DisplayType.DateTime) else if (pdc.getDisplayType() == DisplayType.DateTime)
{ {
Timestamp datetime = rs.getTimestamp(counter++); Timestamp datetime = rs.getTimestamp(counter++);
pde = new PrintDataElement(pdc.getColumnName(), datetime, pdc.getDisplayType(), pdc.getFormatPattern()); pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), datetime, pdc.getDisplayType(), pdc.getFormatPattern());
} }
else else
// The general case // The general case
@ -1118,10 +1119,10 @@ public class DataEngine
{ {
String s = (String)obj; String s = (String)obj;
s = Msg.parseTranslation(pd.getCtx(), s); s = Msg.parseTranslation(pd.getCtx(), s);
pde = new PrintDataElement(pdc.getColumnName(), s, pdc.getDisplayType(), pdc.getFormatPattern()); pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), s, pdc.getDisplayType(), pdc.getFormatPattern());
} }
else else
pde = new PrintDataElement(pdc.getColumnName(), (Serializable)obj, pdc.getDisplayType(), pdc.getFormatPattern()); pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), (Serializable)obj, pdc.getDisplayType(), pdc.getFormatPattern());
} }
} }
} // Value only } // Value only
@ -1131,7 +1132,7 @@ public class DataEngine
/** Report Summary FR [ 2011569 ]**/ /** Report Summary FR [ 2011569 ]**/
if(!m_summary) if(!m_summary)
pd.addNode(pde); pd.addNode(pde);
m_group.addValue(pde.getColumnName(), pde.getFunctionValue()); m_group.addValue(pde.getAD_PrintFormatItem_ID(), pde.getFunctionValue());
} }
} // for all columns } // for all columns
@ -1155,12 +1156,12 @@ public class DataEngine
for (int i = pd.getColumnInfo().length-1; i >= 0; i--) // backwards (leaset group first) for (int i = pd.getColumnInfo().length-1; i >= 0; i--) // backwards (leaset group first)
{ {
PrintDataColumn group_pdc = pd.getColumnInfo()[i]; PrintDataColumn group_pdc = pd.getColumnInfo()[i];
if (!m_group.isGroupColumn(group_pdc.getColumnName())) if (!m_group.isGroupColumn(group_pdc.getAD_PrintFormatItem_ID()))
continue; continue;
Object value = m_group.groupChange(group_pdc.getColumnName(), new Object(), false); Object value = m_group.groupChange(group_pdc.getAD_PrintFormatItem_ID(), new Object(), false);
if (value != null) // Group change if (value != null) // Group change
{ {
char[] functions = m_group.getFunctions(group_pdc.getColumnName()); char[] functions = m_group.getFunctions(group_pdc.getAD_PrintFormatItem_ID());
for (int f = 0; f < functions.length; f++) for (int f = 0; f < functions.length; f++)
{ {
printRunningTotal(pd, levelNo, rowNo++); printRunningTotal(pd, levelNo, rowNo++);
@ -1176,14 +1177,14 @@ public class DataEngine
valueString = DisplayType.getDateFormat(pdc.getDisplayType(), m_language).format(value); valueString = DisplayType.getDateFormat(pdc.getDisplayType(), m_language).format(value);
if (format.getTableFormat().isPrintFunctionSymbols()) // Translate Sum, etc. if (format.getTableFormat().isPrintFunctionSymbols()) // Translate Sum, etc.
valueString += PrintDataFunction.getFunctionSymbol(functions[f]); valueString += PrintDataFunction.getFunctionSymbol(functions[f]);
pd.addNode(new PrintDataElement(pdc.getColumnName(), pd.addNode(new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(),
valueString, DisplayType.String, pdc.getFormatPattern())); valueString, DisplayType.String, pdc.getFormatPattern()));
} }
else if (m_group.isFunctionColumn(pdc.getColumnName(), functions[f])) else if (m_group.isFunctionColumn(pdc.getAD_PrintFormatItem_ID(), functions[f]))
{ {
pd.addNode(new PrintDataElement(pdc.getColumnName(), pd.addNode(new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(),
m_group.getValue(group_pdc.getColumnName(), m_group.getValue(group_pdc.getAD_PrintFormatItem_ID(),
pdc.getColumnName(), functions[f]), pdc.getAD_PrintFormatItem_ID(), functions[f]),
PrintDataFunction.getFunctionDisplayType(functions[f], PrintDataFunction.getFunctionDisplayType(functions[f],
pdc.getDisplayType()),pdc.getFormatPattern())); pdc.getDisplayType()),pdc.getFormatPattern()));
} }
@ -1213,14 +1214,14 @@ public class DataEngine
name = Msg.getMsg(format.getLanguage(), PrintDataFunction.getFunctionName(functions[f])); name = Msg.getMsg(format.getLanguage(), PrintDataFunction.getFunctionName(functions[f]));
else else
name = PrintDataFunction.getFunctionSymbol(functions[f]); // Symbol name = PrintDataFunction.getFunctionSymbol(functions[f]); // Symbol
pd.addNode(new PrintDataElement(pdc.getColumnName(), name.trim(), pd.addNode(new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), name.trim(),
DisplayType.String, pdc.getFormatPattern())); DisplayType.String, pdc.getFormatPattern()));
} }
else if (m_group.isFunctionColumn(pdc.getColumnName(), functions[f])) else if (m_group.isFunctionColumn(pdc.getAD_PrintFormatItem_ID(), functions[f]))
{ {
pd.addNode(new PrintDataElement(pdc.getColumnName(), pd.addNode(new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(),
m_group.getValue(PrintDataGroup.TOTAL, m_group.getValue(PrintDataGroup.TOTAL,
pdc.getColumnName(), functions[f]), pdc.getAD_PrintFormatItem_ID(), functions[f]),
PrintDataFunction.getFunctionDisplayType(functions[f], pdc.getDisplayType()), pdc.getFormatPattern())); PrintDataFunction.getFunctionDisplayType(functions[f], pdc.getDisplayType()), pdc.getFormatPattern()));
} }
} // for all columns } // for all columns
@ -1273,13 +1274,13 @@ public class DataEngine
if (c == 0) if (c == 0)
{ {
String title = "RunningTotal"; String title = "RunningTotal";
pd.addNode(new PrintDataElement(pdc.getColumnName(), pd.addNode(new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(),
title, DisplayType.String, false, rt==0, pdc.getFormatPattern())); // page break title, DisplayType.String, false, rt==0, pdc.getFormatPattern())); // page break
} }
else if (m_group.isFunctionColumn(pdc.getColumnName(), PrintDataFunction.F_SUM)) else if (m_group.isFunctionColumn(pdc.getAD_PrintFormatItem_ID(), PrintDataFunction.F_SUM))
{ {
pd.addNode(new PrintDataElement(pdc.getColumnName(), pd.addNode(new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(),
m_group.getValue(PrintDataGroup.TOTAL, pdc.getColumnName(), PrintDataFunction.F_SUM), m_group.getValue(PrintDataGroup.TOTAL, pdc.getAD_PrintFormatItem_ID(), PrintDataFunction.F_SUM),
PrintDataFunction.getFunctionDisplayType(PrintDataFunction.F_SUM, PrintDataFunction.getFunctionDisplayType(PrintDataFunction.F_SUM,
pdc.getDisplayType()), false, false, pdc.getFormatPattern())); pdc.getDisplayType()), false, false, pdc.getFormatPattern()));
} }

View File

@ -255,7 +255,7 @@ public class PrintData implements Serializable
if (functionRow) if (functionRow)
m_functionRows.add(Integer.valueOf(m_matrix.getRowIndex())); m_functionRows.add(Integer.valueOf(m_matrix.getRowIndex()));
if (m_hasLevelNo && levelNo != 0) if (m_hasLevelNo && levelNo != 0)
addNode(new PrintDataElement(LEVEL_NO, Integer.valueOf(levelNo), DisplayType.Integer, null)); addNode(new PrintDataElement(0, LEVEL_NO, Integer.valueOf(levelNo), DisplayType.Integer, null));
} // addRow } // addRow
/** /**
@ -448,6 +448,7 @@ public class PrintData implements Serializable
* @param AD_Column_ID AD_Column_ID * @param AD_Column_ID AD_Column_ID
* @return PrintData(Element) with AD_Column_ID or null * @return PrintData(Element) with AD_Column_ID or null
*/ */
@Deprecated
public Object getNode (Integer AD_Column_ID) public Object getNode (Integer AD_Column_ID)
{ {
int index = getIndex (AD_Column_ID.intValue()); int index = getIndex (AD_Column_ID.intValue());
@ -457,6 +458,30 @@ public class PrintData implements Serializable
return nodes.get(index); return nodes.get(index);
} // getNode } // getNode
/**
*
* @param item
* @return PrintData(Element) with AD_PrintFormatItem_ID or null
*/
public Object getNodeByPrintFormatItem(MPrintFormatItem item)
{
return getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
}
/**
* Get Node with AD_PrintFormatItem_ID in row
* @param AD_PrintFormatItem_ID AD_PrintFormatItem_ID
* @return PrintData(Element) with AD_PrintFormatItem_ID or null
*/
public Object getNodeByPrintFormatItemId (int AD_PrintFormatItem_ID)
{
int index = getIndexOfPrintFormatItem(AD_PrintFormatItem_ID);
if (index < 0)
return null;
List<Serializable> nodes = m_matrix.getRowData();
return nodes.get(index);
} // getNode
/** /**
* Get Primary Key in row * Get Primary Key in row
* @return PK or null * @return PK or null
@ -515,6 +540,7 @@ public class PrintData implements Serializable
* @param AD_Column_ID AD_Column_ID * @param AD_Column_ID AD_Column_ID
* @return index or -1 * @return index or -1
*/ */
@Deprecated
public int getIndex (int AD_Column_ID) public int getIndex (int AD_Column_ID)
{ {
if (m_columnInfo == null) if (m_columnInfo == null)
@ -530,6 +556,35 @@ public class PrintData implements Serializable
return -1; return -1;
} // getIndex } // getIndex
/**
* Get Index of Node in Structure (not recursing) row
* @param AD_PrintFormatItem_ID AD_PrintFormatItem_ID
* @return index or -1
*/
public int getIndexOfPrintFormatItem(int AD_PrintFormatItem_ID)
{
List<Serializable> nodes = m_matrix.getRowData();
if (nodes == null)
return -1;
for (int i = 0; i < nodes.size(); i++)
{
Object o = nodes.get(i);
if (o instanceof PrintDataElement)
{
if (AD_PrintFormatItem_ID == ((PrintDataElement)o).getAD_PrintFormatItem_ID())
return i;
}
else if (o instanceof PrintData)
{
continue;
}
else
log.log(Level.SEVERE, "Element not PrintData(Element) " + o.getClass().getName());
}
// As Data is stored sparse, there might be lots of NULL values
// log.log(Level.SEVERE, "PrintData.getIndex - Element not found - " + name);
return -1;
}
/************************************************************************** /**************************************************************************
* Dump All Data - header and rows * Dump All Data - header and rows
@ -686,6 +741,7 @@ public class PrintData implements Serializable
if (!pde.isNull()) if (!pde.isNull())
{ {
Element element = document.createElement(PrintDataElement.XML_TAG); Element element = document.createElement(PrintDataElement.XML_TAG);
element.setAttribute(PrintDataElement.XML_ATTRIBUTE_PRINTFORMATITEM_ID, Integer.toString(pde.getAD_PrintFormatItem_ID()));
element.setAttribute(PrintDataElement.XML_ATTRIBUTE_NAME, pde.getColumnName()); element.setAttribute(PrintDataElement.XML_ATTRIBUTE_NAME, pde.getColumnName());
if (pde.hasKey()) if (pde.hasKey())
element.setAttribute(PrintDataElement.XML_ATTRIBUTE_KEY, pde.getValueKey()); element.setAttribute(PrintDataElement.XML_ATTRIBUTE_KEY, pde.getValueKey());
@ -771,39 +827,6 @@ public class PrintData implements Serializable
} // parseXML } // parseXML
/**************************************************************************
* Test
* @param args test
*/
public static void main(String[] args)
{
PrintData pd = new PrintData(new Properties(), "test1");
pd.addNode(new PrintDataElement("test1element1","testvalue<1>",0,null));
pd.addNode(new PrintDataElement("test1element2","testvalue&2&",0,null));
PrintData pdx = new PrintData(new Properties(), "test2");
pdx.addNode(new PrintDataElement("test2element1-1","testvalue11",0,null));
pdx.addNode(new PrintDataElement("test2element1-2","testvalue12",0,null));
pdx.addRow(false, 0, new ArrayList<Serializable>());
pdx.addNode(new PrintDataElement("test2element2-1","testvalue21",0,null));
pdx.addNode(new PrintDataElement("test2element2-2","testvalue22",0,null));
pd.addNode(pdx);
pd.addNode(new PrintDataElement("test1element3","testvalue/3/",0,null));
pd.createXML("C:\\Temp\\printData.xml");
pd.createXML(new StreamResult(System.out));
System.out.println("");
pd.dump();
// parse
System.out.println("");
PrintData pd1 = parseXML (new Properties(), new File("C:\\Temp\\printData.xml"));
pd1.createXML(new StreamResult(System.out));
System.out.println("");
pd1.dump();
} // main
public MReportLine getMReportLine() public MReportLine getMReportLine()
{ {
List<Serializable> nodes = m_matrix.getRowData(); List<Serializable> nodes = m_matrix.getRowData();
@ -834,7 +857,7 @@ public class PrintData implements Serializable
{ {
addRow(functionRow, levelNo); addRow(functionRow, levelNo);
if (m_hasLevelNo && reportLineID != 0) if (m_hasLevelNo && reportLineID != 0)
addNode(new PrintDataElement("PA_ReportLine_ID", reportLineID, DisplayType.Integer, null)); addNode(new PrintDataElement(0, "PA_ReportLine_ID", reportLineID, DisplayType.Integer, null));
} }
} // PrintData } // PrintData

View File

@ -30,6 +30,7 @@ public class PrintDataColumn
/** /**
* Print Data Column * Print Data Column
* *
* @param AD_PrintFormatItem_ID
* @param AD_Column_ID Column * @param AD_Column_ID Column
* @param columnName Column Name * @param columnName Column Name
* @param displayType Display Type * @param displayType Display Type
@ -38,8 +39,9 @@ public class PrintDataColumn
* @param isPageBreak if true force page break after function * @param isPageBreak if true force page break after function
* @param foreignColumnName name foreign * @param foreignColumnName name foreign
*/ */
public PrintDataColumn(int AD_Column_ID, String columnName,int displayType, int columnSize,String alias, boolean isPageBreak, String foreignColumnName) public PrintDataColumn(int AD_PrintFormatItem_ID, int AD_Column_ID, String columnName,int displayType, int columnSize,String alias, boolean isPageBreak, String foreignColumnName)
{ {
m_AD_PrintFormatItem_ID = AD_PrintFormatItem_ID;
m_AD_Column_ID = AD_Column_ID; m_AD_Column_ID = AD_Column_ID;
m_columnName = columnName; m_columnName = columnName;
// //
@ -53,11 +55,12 @@ public class PrintDataColumn
m_foreignColumnName = foreignColumnName; m_foreignColumnName = foreignColumnName;
} }
public PrintDataColumn (int AD_Column_ID, String columnName,int displayType, int columnSize,String alias, boolean isPageBreak) public PrintDataColumn (int AD_PrintFormatItem_ID, int AD_Column_ID, String columnName,int displayType, int columnSize,String alias, boolean isPageBreak)
{ {
this(AD_Column_ID, columnName, displayType, columnSize, alias, isPageBreak, null); this(AD_PrintFormatItem_ID, AD_Column_ID, columnName, displayType, columnSize, alias, isPageBreak, null);
} // PrintDataColumn } // PrintDataColumn
private int m_AD_PrintFormatItem_ID;
private int m_AD_Column_ID; private int m_AD_Column_ID;
private String m_columnName; private String m_columnName;
private String m_foreignColumnName; private String m_foreignColumnName;
@ -69,6 +72,15 @@ public class PrintDataColumn
/*************************************************************************/ /*************************************************************************/
/**
*
* @return AD_PrintFormatItem_ID
*/
public int getAD_PrintFormatItem_ID()
{
return m_AD_PrintFormatItem_ID;
}
/** /**
* Get AD_Column_ID * Get AD_Column_ID
* @return AD_Column_ID * @return AD_Column_ID
@ -143,7 +155,8 @@ public class PrintDataColumn
public String toString() public String toString()
{ {
StringBuilder sb = new StringBuilder("PrintDataColumn["); StringBuilder sb = new StringBuilder("PrintDataColumn[");
sb.append("ID=").append(m_AD_Column_ID) sb.append("AD_PrintFormatItem_ID=").append(m_AD_PrintFormatItem_ID);
sb.append(",AD_Column_ID=").append(m_AD_Column_ID)
.append("-").append(m_columnName); .append("-").append(m_columnName);
if (hasAlias()) if (hasAlias())
sb.append("(").append(m_alias).append(")"); sb.append("(").append(m_alias).append(")");

View File

@ -43,6 +43,7 @@ public class PrintDataElement implements Serializable
/** /**
* Print Data Element Constructor * Print Data Element Constructor
* @param AD_PrintFormatItem_ID
* @param columnName name * @param columnName name
* @param value display value * @param value display value
* @param displayType optional displayType * @param displayType optional displayType
@ -50,10 +51,11 @@ public class PrintDataElement implements Serializable
* @param isPageBreak if true force page break * @param isPageBreak if true force page break
* @param foreignColumnName name foreign * @param foreignColumnName name foreign
*/ */
public PrintDataElement (String columnName, Serializable value, int displayType, boolean isPKey, boolean isPageBreak, String format, String foreignColumnName) public PrintDataElement (int AD_PrintFormatItem_ID, String columnName, Serializable value, int displayType, boolean isPKey, boolean isPageBreak, String format, String foreignColumnName)
{ {
if (columnName == null) if (columnName == null)
throw new IllegalArgumentException("PrintDataElement - Name cannot be null"); throw new IllegalArgumentException("PrintDataElement - Name cannot be null");
m_AD_PrintFormatItem_ID = AD_PrintFormatItem_ID;
m_columnName = columnName; m_columnName = columnName;
m_value = value; m_value = value;
m_displayType = displayType; m_displayType = displayType;
@ -63,28 +65,30 @@ public class PrintDataElement implements Serializable
m_foreignColumnName = foreignColumnName; m_foreignColumnName = foreignColumnName;
} // PrintDataElement } // PrintDataElement
public PrintDataElement(String columnName, Serializable value, int displayType, String pattern, String foreignColumnName) public PrintDataElement(int AD_PrintFormatItem_ID, String columnName, Serializable value, int displayType, String pattern, String foreignColumnName)
{ {
this (columnName, value, displayType, false, false, pattern, foreignColumnName); this (AD_PrintFormatItem_ID, columnName, value, displayType, false, false, pattern, foreignColumnName);
} // PrintDataElement } // PrintDataElement
/** /**
* Print Data Element Constructor * Print Data Element Constructor
* @param AD_PrintFormatItem_ID
* @param columnName name * @param columnName name
* @param value display value * @param value display value
* @param pattern Number/date format pattern * @param pattern Number/date format pattern
* @param displayType optional displayType * @param displayType optional displayType
*/ */
public PrintDataElement(String columnName, Serializable value, int displayType, String pattern) public PrintDataElement(int AD_PrintFormatItem_ID, String columnName, Serializable value, int displayType, String pattern)
{ {
this (columnName, value, displayType, false, false, pattern, null); this (AD_PrintFormatItem_ID, columnName, value, displayType, false, false, pattern, null);
} // PrintDataElement } // PrintDataElement
public PrintDataElement (String columnName, Serializable value, int displayType, boolean isPKey, boolean isPageBreak, String format) public PrintDataElement (int AD_PrintFormatItem_ID, String columnName, Serializable value, int displayType, boolean isPKey, boolean isPageBreak, String format)
{ {
this(columnName, value, displayType, isPKey, isPageBreak, format, null); this(AD_PrintFormatItem_ID, columnName, value, displayType, isPKey, isPageBreak, format, null);
} }
private int m_AD_PrintFormatItem_ID;
/** Data Name */ /** Data Name */
private String m_columnName; private String m_columnName;
/** Data Value */ /** Data Value */
@ -107,7 +111,17 @@ public class PrintDataElement implements Serializable
public static final String XML_ATTRIBUTE_NAME = "name"; public static final String XML_ATTRIBUTE_NAME = "name";
/** XML Attribute Key */ /** XML Attribute Key */
public static final String XML_ATTRIBUTE_KEY = "key"; public static final String XML_ATTRIBUTE_KEY = "key";
/** XML Attribute PrintFormatItem Id */
public static final String XML_ATTRIBUTE_PRINTFORMATITEM_ID = "printformatitem-id";
/**
*
* @return AD_PrintFormatItem_ID
*/
public int getAD_PrintFormatItem_ID()
{
return m_AD_PrintFormatItem_ID;
}
/** /**
* Get Name * Get Name

View File

@ -20,6 +20,7 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
/** /**
* Group By Management * Group By Management
@ -39,27 +40,27 @@ public class PrintDataGroup
/** Column-Function Delimiter */ /** Column-Function Delimiter */
static public final String DELIMITER = "~"; static public final String DELIMITER = "~";
/** Grand Total Indicator */ /** Grand Total Indicator */
static public final String TOTAL = "=TOTAL="; static public final int TOTAL = -1;
/** NULL substitute value */ /** NULL substitute value */
static private final Object NULL = new String(); static private final Object NULL = new String();
/** List of group columns */ /** List of group columns */
private ArrayList<String> m_groups = new ArrayList<String>(); private ArrayList<Integer> m_groups = new ArrayList<Integer>();
/** Map of group column & value */ /** Map of group column & value */
private HashMap<String,Object> m_groupMap = new HashMap<String,Object>(); private HashMap<Integer,Object> m_groupMap = new HashMap<Integer,Object>();
/** List of column_function */ /** List of column_function */
private ArrayList<String> m_functions = new ArrayList<String>(); private HashMap<Integer,List<Character>> m_functions = new HashMap<>();
/** Map of group_function column & function */ /** Map of group_function column & function */
private HashMap<String,PrintDataFunction> m_groupFunction = new HashMap<String,PrintDataFunction>(); private HashMap<String,PrintDataFunction> m_groupFunction = new HashMap<String,PrintDataFunction>();
/************************************************************************** /**************************************************************************
* Add Group Column * Add Group Column
* @param groupColumnName group column * @param AD_PrintFormatItem_ID group column
*/ */
public void addGroupColumn (String groupColumnName) public void addGroupColumn (int AD_PrintFormatItem_ID)
{ {
m_groups.add(groupColumnName); m_groups.add(AD_PrintFormatItem_ID);
} // addGroup } // addGroup
/** /**
@ -74,101 +75,92 @@ public class PrintDataGroup
/** /**
* Column has a function * Column has a function
* @param columnName column name or TOTAL * @param AD_PrintFormatItem_ID column or TOTAL
* @return true if column has function * @return true if column has function
*/ */
public boolean isGroupColumn (String columnName) public boolean isGroupColumn (int AD_PrintFormatItem_ID)
{ {
if (columnName == null || m_groups.size() == 0) return m_groups.contains(AD_PrintFormatItem_ID);
return false;
for (int i = 0; i < m_groups.size(); i++)
{
if (columnName.equals(m_groups.get(i)))
return true;
}
return false;
} // isGroupColumn } // isGroupColumn
/** /**
* Check for Group Change * Check for Group Change
* @param groupColumnName column name * @param AD_PrintFormatItem_ID group column
* @param value column value * @param value column value
* @return null if no group change otherwise old value * @return null if no group change otherwise old value
*/ */
public Object groupChange (String groupColumnName, Object value, boolean force) public Object groupChange (int AD_PrintFormatItem_ID, Object value, boolean force)
{ {
if (!isGroupColumn(groupColumnName)) if (!isGroupColumn(AD_PrintFormatItem_ID))
return null; return null;
Object newValue = value; Object newValue = value;
if (newValue == null) if (newValue == null)
newValue = NULL; newValue = NULL;
// //
if (m_groupMap.containsKey(groupColumnName)) if (m_groupMap.containsKey(AD_PrintFormatItem_ID))
{ {
Object oldValue = m_groupMap.get(groupColumnName); Object oldValue = m_groupMap.get(AD_PrintFormatItem_ID);
if (newValue.equals(oldValue) && !force ) if (newValue.equals(oldValue) && !force )
return null; return null;
m_groupMap.put(groupColumnName, newValue); m_groupMap.put(AD_PrintFormatItem_ID, newValue);
return oldValue; return oldValue;
} }
m_groupMap.put(groupColumnName, newValue); m_groupMap.put(AD_PrintFormatItem_ID, newValue);
return null; return null;
} // groupChange } // groupChange
/************************************************************************** /**************************************************************************
* Add Function Column * Add Function Column
* @param functionColumnName column name * @param AD_PrintFormatItem_ID column
* @param function function * @param function function
*/ */
public void addFunction (String functionColumnName, char function) public void addFunction (int AD_PrintFormatItem_ID, char function)
{ {
m_functions.add(functionColumnName + DELIMITER + function); List<Character> list = m_functions.get(AD_PrintFormatItem_ID);
if (list == null)
{
list = new ArrayList<Character>();
m_functions.put(AD_PrintFormatItem_ID, list);
}
if (!list.contains(function))
list.add(function);
if (!m_groups.contains(TOTAL)) if (!m_groups.contains(TOTAL))
m_groups.add(TOTAL); m_groups.add(TOTAL);
} // addFunction } // addFunction
/** /**
* Column has a function * Column has a function
* @param columnName column name * @param AD_PrintFormatItem_ID column
* @return true if column has function * @return true if column has function
*/ */
public boolean isFunctionColumn (String columnName) public boolean isFunctionColumn (int AD_PrintFormatItem_ID)
{ {
if (columnName == null || m_functions.size() == 0) return m_functions.containsKey(AD_PrintFormatItem_ID);
return false;
for (int i = 0; i < m_functions.size(); i++)
{
String f = (String)m_functions.get(i);
if (f.startsWith(columnName))
return true;
}
return false;
} // isFunctionColumn } // isFunctionColumn
/** /**
* Get calculated functions of column * Get calculated functions of column
* @param columnName column name or TOTAL * @param groupId group column or TOTAL
* @return array of functions * @return array of functions
*/ */
public char[] getFunctions(String columnName) public char[] getFunctions(int groupId)
{ {
ArrayList<String> list = new ArrayList<String>(); // the final function List ArrayList<Character> list = new ArrayList<Character>(); // the final function List
Iterator<String> it = m_groupFunction.keySet().iterator(); Iterator<String> it = m_groupFunction.keySet().iterator();
while(it.hasNext()) while(it.hasNext())
{ {
String group_function = (String)it.next(); // =TOTAL=~LoadSeq String group_function = (String)it.next(); // =TOTAL=~LoadSeq
if (group_function.startsWith(columnName)) if (group_function.startsWith(Integer.toString(groupId)))
{ {
group_function = group_function.substring(group_function.lastIndexOf(DELIMITER)+1); // LoadSeq String functionColumn = group_function.substring(group_function.lastIndexOf(DELIMITER)+1); // LoadSeq
for (int i = 0; i < m_functions.size(); i++) List<Character> fs = m_functions.get(Integer.parseInt(functionColumn));
if (fs != null && fs.size() > 0)
{ {
String col_function = ((String)m_functions.get(i)); // LoadSeq~A for (Character f : fs)
if (col_function.startsWith(group_function))
{ {
String function = col_function.substring(col_function.lastIndexOf(DELIMITER)+1); if (!list.contains(f))
if (!list.contains(function)) list.add(f);
list.add(function);
} }
} }
} }
@ -176,27 +168,29 @@ public class PrintDataGroup
// Return Value // Return Value
char[] retValue = new char[list.size()]; char[] retValue = new char[list.size()];
for (int i = 0; i < retValue.length; i++) for (int i = 0; i < retValue.length; i++)
retValue[i] = ((String)list.get(i)).charAt(0); retValue[i] = list.get(i);
// log.finest( "PrintDataGroup.getFunctions for " + columnName + "/" + retValue.length, new String(retValue)); // log.finest( "PrintDataGroup.getFunctions for " + columnName + "/" + retValue.length, new String(retValue));
return retValue; return retValue;
} // getFunctions } // getFunctions
/** /**
* Column has a function * Column has a function
* @param columnName column name * @param AD_PrintFormatItem_ID column
* @param function function * @param function function
* @return true if column has function * @return true if column has function
*/ */
public boolean isFunctionColumn (String columnName, char function) public boolean isFunctionColumn (int AD_PrintFormatItem_ID, char function)
{ {
if (columnName == null || m_functions.size() == 0) if (m_functions.size() == 0)
return false; return false;
String key = columnName + DELIMITER + function; List<Character> fs = m_functions.get(AD_PrintFormatItem_ID);
for (int i = 0; i < m_functions.size(); i++) if (fs != null && fs.size() > 0)
{ {
String f = (String)m_functions.get(i); for (Character f : fs)
if (f.equals(key)) {
return true; if (f.charValue() == function)
return true;
}
} }
return false; return false;
} // isFunctionColumn } // isFunctionColumn
@ -204,18 +198,18 @@ public class PrintDataGroup
/************************************************************************** /**************************************************************************
* Add Value to groups * Add Value to groups
* @param functionColumnName column name * @param functionColumnId function column
* @param functionValue value * @param functionValue value
*/ */
public void addValue (String functionColumnName, BigDecimal functionValue) public void addValue (int functionColumnId, BigDecimal functionValue)
{ {
if (!isFunctionColumn(functionColumnName)) if (!isFunctionColumn(functionColumnId))
return; return;
// Group Breaks // Group Breaks
for (int i = 0; i < m_groups.size(); i++) for (int i = 0; i < m_groups.size(); i++)
{ {
String groupColumnName = (String)m_groups.get(i); int groupId = m_groups.get(i);
String key = groupColumnName + DELIMITER + functionColumnName; String key = groupId + DELIMITER + functionColumnId;
PrintDataFunction pdf = (PrintDataFunction)m_groupFunction.get(key); PrintDataFunction pdf = (PrintDataFunction)m_groupFunction.get(key);
if (pdf == null) if (pdf == null)
pdf = new PrintDataFunction(); pdf = new PrintDataFunction();
@ -226,15 +220,15 @@ public class PrintDataGroup
/** /**
* Get Value * Get Value
* @param groupColumnName group column name (or TOTAL) * @param groupId group column (or TOTAL)
* @param functionColumnName function column name * @param functionColumnId function column
* @param function function * @param function function
* @return value * @return value
*/ */
public BigDecimal getValue (String groupColumnName, String functionColumnName, public BigDecimal getValue (int groupId, int functionColumnId,
char function) char function)
{ {
String key = groupColumnName + DELIMITER + functionColumnName; String key = groupId + DELIMITER + functionColumnId;
PrintDataFunction pdf = (PrintDataFunction)m_groupFunction.get(key); PrintDataFunction pdf = (PrintDataFunction)m_groupFunction.get(key);
if (pdf == null) if (pdf == null)
return null; return null;
@ -243,12 +237,12 @@ public class PrintDataGroup
/** /**
* Reset Function values * Reset Function values
* @param groupColumnName group column name (or TOTAL) * @param groupId group column (or TOTAL)
* @param functionColumnName function column name * @param functionColumnId function column
*/ */
public void reset (String groupColumnName, String functionColumnName) public void reset (int groupId, int functionColumnId)
{ {
String key = groupColumnName + DELIMITER + functionColumnName; String key = groupId + DELIMITER + functionColumnId;
PrintDataFunction pdf = (PrintDataFunction)m_groupFunction.get(key); PrintDataFunction pdf = (PrintDataFunction)m_groupFunction.get(key);
if (pdf != null) if (pdf != null)
pdf.reset(); pdf.reset();
@ -280,7 +274,7 @@ public class PrintDataGroup
} }
if (withData) if (withData)
{ {
Iterator<String> it = m_groupMap.keySet().iterator(); Iterator<Integer> it = m_groupMap.keySet().iterator();
while(it.hasNext()) while(it.hasNext())
{ {
Object key = it.next(); Object key = it.next();

View File

@ -19,6 +19,7 @@ package org.compiere.print;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import org.compiere.util.Util;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
@ -45,6 +46,7 @@ public class PrintDataHandler extends DefaultHandler
/** Final Structure */ /** Final Structure */
private PrintData m_pd = null; private PrintData m_pd = null;
private String m_curPrintFormatItemId = null;
/** Current Active Element Name */ /** Current Active Element Name */
private String m_curPDEname = null; private String m_curPDEname = null;
/** Current Active Element Value */ /** Current Active Element Value */
@ -96,6 +98,7 @@ public class PrintDataHandler extends DefaultHandler
} }
else if (qName.equals(PrintDataElement.XML_TAG)) else if (qName.equals(PrintDataElement.XML_TAG))
{ {
m_curPrintFormatItemId = attributes.getValue(PrintDataElement.XML_ATTRIBUTE_PRINTFORMATITEM_ID);
m_curPDEname = attributes.getValue(PrintDataElement.XML_ATTRIBUTE_NAME); m_curPDEname = attributes.getValue(PrintDataElement.XML_ATTRIBUTE_NAME);
m_curPDEvalue = new StringBuffer(); m_curPDEvalue = new StringBuffer();
} }
@ -131,7 +134,16 @@ public class PrintDataHandler extends DefaultHandler
} }
else if (qName.equals(PrintDataElement.XML_TAG)) else if (qName.equals(PrintDataElement.XML_TAG))
{ {
m_curPD.addNode(new PrintDataElement(m_curPDEname, m_curPDEvalue.toString(),0, null)); int id = 0;
if (!Util.isEmpty(m_curPrintFormatItemId, true))
{
try
{
id = Integer.parseInt(m_curPrintFormatItemId);
}
catch (Exception ex) {}
}
m_curPD.addNode(new PrintDataElement(id, m_curPDEname, m_curPDEvalue.toString(),0, null));
} }
} // endElement } // endElement

View File

@ -849,16 +849,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
{ {
td td = new td(); td td = new td();
tr.addElement(td); tr.addElement(td);
Object obj = null; Object obj = m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
/** START DEVCOFFEE: script column **/
if (item.isTypeScript())
{
obj = m_printData.getNode(item.getName());
}
else
{
obj = m_printData.getNode(Integer.valueOf(item.getAD_Column_ID()));
}
if (obj == null || !isDisplayPFItem(item)){ if (obj == null || !isDisplayPFItem(item)){
td.addElement("&nbsp;"); td.addElement("&nbsp;");
if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){ if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){
@ -1074,13 +1065,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
else else
{ {
printColIndex++; printColIndex++;
Object obj = m_printData.getNode(Integer.valueOf(item.getAD_Column_ID())); Object obj = m_printData.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
String data = ""; String data = "";
/** START DEVCOFFEE: script column **/
if (item.isTypeScript())
{
obj = m_printData.getNode(item.getName());
}
if (obj == null || !isDisplayPFItem(item)){ if (obj == null || !isDisplayPFItem(item)){
if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){ if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){
preValues[printColIndex] = null; preValues[printColIndex] = null;

View File

@ -1267,7 +1267,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
int AD_Column_ID = item.getAD_Column_ID(); int AD_Column_ID = item.getAD_Column_ID();
if (log.isLoggable(Level.INFO)) log.info(format + " - Item=" + item.getName() + " (" + AD_Column_ID + ")"); if (log.isLoggable(Level.INFO)) log.info(format + " - Item=" + item.getName() + " (" + AD_Column_ID + ")");
// //
Object obj = data.getNode(Integer.valueOf(AD_Column_ID)); Object obj = data.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
// Object obj = data.getNode(item.getColumnName()); // slower // Object obj = data.getNode(item.getColumnName()); // slower
if (obj == null) if (obj == null)
{ {
@ -1398,7 +1398,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
String FieldAlignmentType, boolean isForm) String FieldAlignmentType, boolean isForm)
{ {
// Get Data // Get Data
Object obj = m_data.getNode(Integer.valueOf(item.getAD_Column_ID())); Object obj = m_data.getNodeByPrintFormatItemId(item.getAD_PrintFormatItem_ID());
if (obj == null) if (obj == null)
return null; return null;
else if (obj instanceof PrintDataElement) else if (obj instanceof PrintDataElement)
@ -1514,7 +1514,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
*/ */
private PrintElement createImageElement (MPrintFormatItem item, PrintData printData) private PrintElement createImageElement (MPrintFormatItem item, PrintData printData)
{ {
Object obj = printData.getNode(Integer.valueOf(item.getAD_Column_ID())); Object obj = printData.getNodeByPrintFormatItem(item);
if (obj == null) if (obj == null)
return null; return null;
else if (obj instanceof PrintDataElement) else if (obj instanceof PrintDataElement)
@ -1553,7 +1553,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
private PrintElement createBarcodeElement (MPrintFormatItem item, PrintData printData) private PrintElement createBarcodeElement (MPrintFormatItem item, PrintData printData)
{ {
// Get Data // Get Data
Object obj = printData.getNode(Integer.valueOf(item.getAD_Column_ID())); Object obj = printData.getNodeByPrintFormatItem(item);
if (obj == null) if (obj == null)
return null; return null;
else if (obj instanceof PrintDataElement) else if (obj instanceof PrintDataElement)
@ -1816,14 +1816,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
} }
else if (item.isTypeField() || item.getPrintFormatType().equals(MPrintFormatItem.PRINTFORMATTYPE_Script)) else if (item.isTypeField() || item.getPrintFormatType().equals(MPrintFormatItem.PRINTFORMATTYPE_Script))
{ {
Object obj = null; Object obj = printData.getNodeByPrintFormatItem(item);
if (item.getAD_Column_ID() > 0) // teo_sarca, [ 1673542 ]
obj = printData.getNode(Integer.valueOf(item.getAD_Column_ID()));
/** START DEVCOFFEE: Script print format type **/
if (item.getPrintFormatType().equals(MPrintFormatItem.PRINTFORMATTYPE_Script))
{
obj = printData.getNode(item.getName());
}
if (obj == null) if (obj == null)
; ;
else if (obj instanceof PrintDataElement) else if (obj instanceof PrintDataElement)

View File

@ -133,7 +133,7 @@ public class ReportEngineEx { //extends ReportEngine {
{ {
td td = new td(); td td = new td();
tr.addElement(td); tr.addElement(td);
Object obj = m_printData.getNode(Integer.valueOf(item.getAD_Column_ID())); Object obj = m_printData.getNodeByPrintFormatItem(item);
if (obj == null) if (obj == null)
td.addElement("&nbsp;"); td.addElement("&nbsp;");
else if (obj instanceof PrintDataElement) else if (obj instanceof PrintDataElement)