use of org.compiere.print.MPrintFormatItem in project adempiere by adempiere.
the class LayoutEngine method layoutTable.
// getColor
/**************************************************************************
* Layout Table.
* Convert PrintData into TableElement
* @param format format to use
* @param printData data to use
* @param xOffset X Axis - offset (start of table) i.e. indentation
* @return TableElement
*/
private PrintElement layoutTable(MPrintFormat format, PrintData printData, int xOffset) {
log.info(format.getName() + " - " + printData.getName());
MPrintTableFormat tf = format.getTableFormat();
// Initial Values
HashMap<Point, Font> rowColFont = new HashMap<Point, Font>();
MPrintFont printFont = MPrintFont.get(format.getAD_PrintFont_ID());
rowColFont.put(new Point(TableElement.ALL, TableElement.ALL), printFont.getFont());
tf.setStandard_Font(printFont.getFont());
rowColFont.put(new Point(TableElement.HEADER_ROW, TableElement.ALL), tf.getHeader_Font());
//
HashMap<Point, Color> rowColColor = new HashMap<Point, Color>();
MPrintColor printColor = MPrintColor.get(getCtx(), format.getAD_PrintColor_ID());
rowColColor.put(new Point(TableElement.ALL, TableElement.ALL), printColor.getColor());
rowColColor.put(new Point(TableElement.HEADER_ROW, TableElement.ALL), tf.getHeaderFG_Color());
//
HashMap<Point, Color> rowColBackground = new HashMap<Point, Color>();
rowColBackground.put(new Point(TableElement.HEADER_ROW, TableElement.ALL), tf.getHeaderBG_Color());
// Sizes
boolean multiLineHeader = tf.isMultiLineHeader();
int pageNoStart = m_pageNo;
int repeatedColumns = 1;
Rectangle firstPage = new Rectangle(m_content);
firstPage.x += xOffset;
firstPage.width -= xOffset;
int yOffset = (int) m_position[AREA_CONTENT].y - m_content.y;
firstPage.y += yOffset;
firstPage.height -= yOffset;
Rectangle nextPages = new Rectangle(m_content);
nextPages.x += xOffset;
nextPages.width -= xOffset;
// Column count
int columnCount = 0;
for (int c = 0; c < format.getItemCount(); c++) {
if (format.getItem(c).isPrinted())
columnCount++;
}
// System.out.println("Cols=" + cols);
// Header & Column Setup
ValueNamePair[] columnHeader = new ValueNamePair[columnCount];
int[] columnMaxWidth = new int[columnCount];
int[] columnMaxHeight = new int[columnCount];
boolean[] fixedWidth = new boolean[columnCount];
boolean[] colSuppressRepeats = new boolean[columnCount];
String[] columnJustification = new String[columnCount];
HashMap<Integer, Integer> additionalLines = new HashMap<Integer, Integer>();
int col = 0;
for (int c = 0; c < format.getItemCount(); c++) {
MPrintFormatItem item = format.getItem(c);
if (item.isPrinted()) {
if (item.isNextLine() && item.getBelowColumn() != 0) {
additionalLines.put(new Integer(col), new Integer(item.getBelowColumn() - 1));
if (!item.isSuppressNull()) {
// display size will be set to 0 in TableElement
item.setIsSuppressNull(true);
item.saveEx();
}
}
columnHeader[col] = new ValueNamePair(item.getColumnName(), item.getPrintName(format.getLanguage()));
columnMaxWidth[col] = item.getMaxWidth();
fixedWidth[col] = (columnMaxWidth[col] != 0 && item.isFixedWidth());
colSuppressRepeats[col] = item.isSuppressRepeats();
if (item.isSuppressNull()) {
if (columnMaxWidth[col] == 0)
// indication suppress if Null
columnMaxWidth[col] = -1;
else
columnMaxWidth[col] *= -1;
}
columnMaxHeight[col] = item.getMaxHeight();
if (item.isHeightOneLine())
columnMaxHeight[col] = -1;
columnJustification[col] = item.getFieldAlignmentType();
if (columnJustification[col] == null || columnJustification[col].equals(MPrintFormatItem.FIELDALIGNMENTTYPE_Default))
// when generated sets correct alignment
columnJustification[col] = MPrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft;
// Column Fonts
if (item.getAD_PrintFont_ID() != 0 && item.getAD_PrintFont_ID() != format.getAD_PrintFont_ID()) {
MPrintFont font = MPrintFont.get(item.getAD_PrintFont_ID());
rowColFont.put(new Point(TableElement.ALL, col), font.getFont());
}
if (item.getAD_PrintColor_ID() != 0 && item.getAD_PrintColor_ID() != format.getAD_PrintColor_ID()) {
MPrintColor color = MPrintColor.get(getCtx(), item.getAD_PrintColor_ID());
rowColColor.put(new Point(TableElement.ALL, col), color.getColor());
}
//
col++;
}
}
// The Data
int rows = printData.getRowCount();
// System.out.println("Rows=" + rows);
Object[][] data = new Object[rows][columnCount];
KeyNamePair[] pk = new KeyNamePair[rows];
String pkColumnName = null;
ArrayList<Integer> functionRows = new ArrayList<Integer>();
ArrayList<Integer> pageBreak = new ArrayList<Integer>();
// for all rows
for (int row = 0; row < rows; row++) {
// System.out.println("row=" + row);
printData.setRowIndex(row);
if (printData.isFunctionRow()) {
functionRows.add(new Integer(row));
rowColFont.put(new Point(row, TableElement.ALL), tf.getFunct_Font());
rowColColor.put(new Point(row, TableElement.ALL), tf.getFunctFG_Color());
rowColBackground.put(new Point(row, TableElement.ALL), tf.getFunctBG_Color());
if (printData.isPageBreak()) {
pageBreak.add(new Integer(row));
log.finer("PageBreak row=" + row);
}
} else // Summary/Line Levels for Finanial Reports
{
int levelNo = printData.getLineLevelNo();
if (levelNo != 0) {
if (levelNo < 0)
levelNo = -levelNo;
Font base = printFont.getFont();
if (levelNo == 1)
rowColFont.put(new Point(row, TableElement.ALL), new Font(base.getName(), Font.ITALIC, base.getSize() - levelNo));
else if (levelNo == 2)
rowColFont.put(new Point(row, TableElement.ALL), new Font(base.getName(), Font.PLAIN, base.getSize() - levelNo));
}
}
// for all columns
col = 0;
for (int c = 0; c < format.getItemCount(); c++) {
MPrintFormatItem item = format.getItem(c);
Object dataElement = null;
if (// Text Columns
item.isPrinted()) {
if (item.isTypeImage()) {
if (item.isImageField())
data[row][col] = createImageElement(item);
else if (item.isImageIsAttached())
data[row][col] = ImageElement.get(item.get_ID());
else
data[row][col] = ImageElement.get(item.getImageURL());
// Image layout - teo_sarca, [ 1673548 ]
if (data[row][col] != null)
((ImageElement) data[row][col]).layout(item.getMaxWidth(), item.getMaxHeight(), false, item.getFieldAlignmentType());
} else if (item.isBarcode()) {
Object obj = null;
if (// teo_sarca, [ 1673542 ]
item.getAD_Column_ID() > 0)
obj = printData.getNode(new Integer(item.getAD_Column_ID()));
if (obj == null)
;
else if (obj instanceof PrintDataElement) {
PrintDataElement pde = (PrintDataElement) obj;
// Get the PrintDataElement string value - teo_sarca [ 1673505 ]
String value = null;
Object o = pde.getValue();
if (o == null)
value = "";
if (o instanceof KeyNamePair)
value = ((KeyNamePair) o).getID();
else
value = o.toString();
BarcodeElement element = new BarcodeElement(value, item);
if (element.isValid())
data[row][col] = element;
}
if (data[row][col] != null)
((BarcodeElement) data[row][col]).layout(item.getMaxWidth(), item.getMaxHeight(), false, item.getFieldAlignmentType());
} else if (item.isTypeText()) {
data[row][col] = item.getPrintName(format.getLanguage());
} else if (item.isTypeField()) {
Object obj = null;
if (// teo_sarca, [ 1673542 ]
item.getAD_Column_ID() > 0)
obj = printData.getNode(new Integer(item.getAD_Column_ID()));
if (obj == null)
;
else if (obj instanceof PrintDataElement) {
PrintDataElement pde = (PrintDataElement) obj;
if (pde.isID() || pde.isYesNo())
dataElement = pde.getValue();
else
dataElement = pde.getValueDisplay(format.getLanguage());
} else
log.log(Level.SEVERE, "Element not PrintDataElement " + obj.getClass());
// System.out.println(" row=" + row + ",col=" + col + " - " + item.getAD_Column_ID() + " => " + dataElement);
data[row][col] = dataElement;
} else if (item.isTypePrintFormat()) {
m_currPage.addElement(includeFormat(item, printData));
} else // item.isTypeBox() or isTypePrintFormat()
{
log.warning("Unsupported: " + (item.isTypeBox() ? "Box" : "PrintFormat") + " in Table: " + item);
}
col++;
}
// printed
}
// for all columns
PrintDataElement pde = printData.getPKey();
if (// for FunctionRows
pde != null) {
pk[row] = (KeyNamePair) pde.getValue();
if (pkColumnName == null)
pkColumnName = pde.getColumnName();
}
// else
// System.out.println("No PK " + printData);
}
// for all rows
//
TableElement table = new TableElement(columnHeader, columnMaxWidth, columnMaxHeight, columnJustification, fixedWidth, functionRows, multiLineHeader, data, pk, pkColumnName, pageNoStart, firstPage, nextPages, repeatedColumns, additionalLines, rowColFont, rowColColor, rowColBackground, tf, pageBreak, colSuppressRepeats);
table.layout(0, 0, false, MPrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft);
if (m_tableElement == null)
m_tableElement = table;
return table;
}
use of org.compiere.print.MPrintFormatItem in project adempiere by adempiere.
the class ReportEngineEx method createEXCEL_HTML.
// createHTML
/**
* Write EXCEL HTML to writer
* @param writer writer
* @param onlyTable if false create complete HTML document
* @param language optional language - if null nubers/dates are not formatted
* @return true if success
*/
public static boolean createEXCEL_HTML(ReportEngine re, Properties m_ctx, Writer writer, boolean onlyTable, Language language) {
PrintData m_printData = re.getPrintData();
MPrintFormat m_printFormat = re.getPrintFormat();
///Properties m_ctx = new Properties();
MQuery m_query = re.getQuery();
try {
table table = new table();
// for all rows (-1 = header row)
for (int row = -1; row < m_printData.getRowCount(); row++) {
tr tr = new tr();
table.addElement(tr);
if (row != -1)
m_printData.setRowIndex(row);
// for all columns
for (int col = 0; col < m_printFormat.getItemCount(); col++) {
MPrintFormatItem item = m_printFormat.getItem(col);
if (item.isPrinted()) {
// header row
if (row == -1) {
th th = new th();
tr.addElement(th);
th.addElement(Util.maskHTML(item.getPrintName(language)));
th.setClass("xl_head");
} else {
td td = new td();
tr.addElement(td);
Object obj = m_printData.getNode(new Integer(item.getAD_Column_ID()));
if (obj == null)
td.addElement(" ");
else if (obj instanceof PrintDataElement) {
// formatted
String value = ((PrintDataElement) obj).getValueDisplay(null);
int displayType = ((PrintDataElement) obj).getDisplayType();
if (((PrintDataElement) obj).isNumeric()) {
if (displayType == DisplayType.Integer) {
td.addAttribute("x:num", value);
td.addElement(Util.maskHTML(value));
} else if (displayType == DisplayType.Quantity) {
td.addAttribute("x:num", value);
td.addElement(Util.maskHTML(value));
} else if (displayType == DisplayType.Amount) {
td.addAttribute("x:num", value);
td.addElement(Util.maskHTML(value));
} else if (displayType == DisplayType.CostPrice) {
td.addAttribute("x:num", "");
td.addAttribute("u1:num", value);
td.setClass("xl25");
td.addElement(Util.maskHTML(value));
} else //else if (displayType == DisplayType.YesNo)
//{
//}
// if (displayType == Number)
{
td.addElement(Util.maskHTML(value));
}
} else if (((PrintDataElement) obj).isDate()) {
if (displayType == DisplayType.Date) {
td.setClass("xl24");
td.addElement(Util.maskHTML(value));
} else if (displayType == DisplayType.DateTime) {
td.setClass("xl26");
td.addElement(Util.maskHTML(value));
} else {
td.addElement(Util.maskHTML(value));
}
} else
td.addElement(Util.maskHTML(value));
} else if (obj instanceof PrintData) {
// ignore contained Data
} else
log.log(Level.SEVERE, "createHTML - Element not PrintData(Element) " + obj.getClass());
}
}
// printed
}
// for all columns
}
// for all rows
table table1 = new table();
table1.setBorder(0).setCols(10).setCellPadding(0).setCellSpacing(2);
table1.addElement(new tr().addElement(new td().setColSpan(10).addElement(new h1(re.getName())).setStyle("border:none;")));
tr tr1;
String tmp = "Jednostka: ";
MOrg o = MOrg.get(m_ctx, Env.getAD_Org_ID(m_ctx));
tmp += o.getName();
tr1 = new tr();
tr1.addElement(new td().addElement(tmp).setColSpan(10).setStyle("border:none;"));
table1.addElement(tr1);
java.text.DateFormat dateFormat = java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL, new Locale("pl_PL"));
String dateData = "Czas wygenerowania: " + dateFormat.format(new java.util.Date());
tr1 = new tr();
tr1.addElement(new td().addElement(dateData).setColSpan(10).setStyle("border:none;"));
table1.addElement(tr1);
for (int r = 0; r < m_query.getRestrictionCount(); r++) {
tr1 = new tr();
td td1 = new td().addElement(new i(m_query.getInfoName(r)));
td1.addElement(" " + m_query.getInfoOperator(r) + " " + m_query.getInfoDisplayAll(r)).setColSpan(10);
td1.setStyle("border:none;");
tr1.addElement(td1);
table1.addElement(tr1);
}
tr1 = new tr();
tr1.addElement(new td().addElement(" ").setColSpan(10).setStyle("border:none;height:20px;"));
table1.addElement(tr1);
//
PrintWriter w = new PrintWriter(writer);
if (onlyTable)
table.output(w);
else {
XhtmlDocument doc = new XhtmlDocument();
String st = "<!--table " + " {mso-displayed-decimal-separator:\".\"; " + " mso-displayed-thousand-separator:\" \";} " + "@page " + " {margin:.98in .79in .98in .79in; " + " mso-header-margin:.5in; " + " mso-footer-margin:.5in;} " + "tr " + " {mso-height-source:auto;} " + "col " + " {mso-width-source:auto;} " + "br " + " {mso-data-placement:same-cell;} " + ".style0 " + " {mso-number-format:General; " + " text-align:general; " + " vertical-align:bottom; " + " white-space:nowrap; " + " mso-rotate:0; " + " mso-background-source:auto; " + " mso-pattern:auto; " + " color:windowtext; " + " font-size:10.0pt; " + " font-weight:400; " + " font-style:normal; " + " text-decoration:none; " + " font-family:Arial; " + " mso-generic-font-family:auto; " + " mso-font-charset:238; " + " border:none; " + " mso-protection:locked visible; " + " mso-style-name:Normalny; " + " mso-style-id:0;} " + "td " + " {mso-style-parent:style0; " + " padding-top:1px; " + " padding-right:1px; " + " padding-left:1px; " + " mso-ignore:padding; " + " color:windowtext; " + " font-size:10.0pt; " + " font-weight:400; " + " font-style:normal; " + " text-decoration:none; " + " font-family:Arial; " + " mso-generic-font-family:auto; " + " mso-font-charset:238; " + " mso-number-format:General; " + " text-align:general; " + " vertical-align:bottom; " + //" border:none; "+
"border:.5pt solid #a0a0a0; " + //windowtext
" mso-background-source:auto; " + " mso-pattern:auto; " + " mso-protection:locked visible; " + " white-space:nowrap; " + " mso-rotate:0;} " + ".xl24 " + "{mso-style-parent:style0; " + "mso-number-format:\"Short Date\";} " + ".xl25 " + "{mso-style-parent:style0; " + "mso-number-format:Fixed;} " + ".xl26 " + "{mso-style-parent:style0; " + "mso-number-format:\"yy\\/mm\\/dd\\ h\\:mm\\;\\@\";} " + ".xl_head " + "{text-align:center; mso-style-parent:style0; " + "font-weight:700; " + "font-family:Arial, sans-serif; " + "mso-font-charset:238; " + "border:.5pt solid windowtext; " + "background:silver; " + "mso-pattern:auto none;} " + "--> ";
doc.appendHead(new style().addElement(st));
doc.appendBody(table1);
doc.appendBody(table);
doc.output(w);
}
w.flush();
w.close();
} catch (Exception e) {
log.log(Level.SEVERE, "createHTML(w)", e);
}
return false;
}
use of org.compiere.print.MPrintFormatItem in project adempiere by adempiere.
the class FinReport method getPrintFormat.
/**************************************************************************
* Get/Create PrintFormat
* @return print format
*/
private MPrintFormat getPrintFormat() {
int AD_PrintFormat_ID = m_report.getAD_PrintFormat_ID();
log.info("AD_PrintFormat_ID=" + AD_PrintFormat_ID);
MPrintFormat pf = null;
boolean createNew = AD_PrintFormat_ID == 0;
// Create New
if (createNew) {
// T_Report
int AD_Table_ID = 544;
pf = MPrintFormat.createFromTable(Env.getCtx(), AD_Table_ID);
AD_PrintFormat_ID = pf.getAD_PrintFormat_ID();
m_report.setAD_PrintFormat_ID(AD_PrintFormat_ID);
m_report.saveEx();
} else
// use Cache
pf = MPrintFormat.get(getCtx(), AD_PrintFormat_ID, false);
// Print Format Sync
if (!m_report.getName().equals(pf.getName()))
pf.setName(m_report.getName());
if (m_report.getDescription() == null) {
if (pf.getDescription() != null)
pf.setDescription(null);
} else if (!m_report.getDescription().equals(pf.getDescription()))
pf.setDescription(m_report.getDescription());
pf.saveEx();
log.fine(pf + " - #" + pf.getItemCount());
// Print Format Item Sync
int count = pf.getItemCount();
for (int i = 0; i < count; i++) {
MPrintFormatItem pfi = pf.getItem(i);
String ColumnName = pfi.getColumnName();
//
if (ColumnName == null) {
log.log(Level.SEVERE, "No ColumnName for #" + i + " - " + pfi);
if (pfi.isPrinted())
pfi.setIsPrinted(false);
if (pfi.isOrderBy())
pfi.setIsOrderBy(false);
if (pfi.getSortNo() != 0)
pfi.setSortNo(0);
} else if (ColumnName.startsWith("Col")) {
int index = Integer.parseInt(ColumnName.substring(4));
if (index < m_columns.length) {
pfi.setIsPrinted(m_columns[index].isPrinted());
String s = m_columns[index].getName();
if (m_columns[index].isColumnTypeRelativePeriod()) {
BigDecimal relativeOffset = m_columns[index].getRelativePeriod();
FinReportPeriod frp = getPeriod(relativeOffset);
if (s.contains("@Period@"))
s = s.replace("@Period@", frp.getName());
}
if (!pfi.getName().equals(s)) {
pfi.setName(s);
pfi.setPrintName(s);
}
int seq = 50 + index;
if (pfi.getSeqNo() != seq)
pfi.setSeqNo(seq);
s = m_columns[index].getFormatPattern();
pfi.setFormatPattern(s);
} else // not printed
{
if (pfi.isPrinted())
pfi.setIsPrinted(false);
}
// Not Sorted
if (pfi.isOrderBy())
pfi.setIsOrderBy(false);
if (pfi.getSortNo() != 0)
pfi.setSortNo(0);
} else if (ColumnName.equals("SeqNo")) {
if (pfi.isPrinted())
pfi.setIsPrinted(false);
if (!pfi.isOrderBy())
pfi.setIsOrderBy(true);
if (pfi.getSortNo() != 10)
pfi.setSortNo(10);
} else if (ColumnName.equals("LevelNo")) {
if (pfi.isPrinted())
pfi.setIsPrinted(false);
if (!pfi.isOrderBy())
pfi.setIsOrderBy(true);
if (pfi.getSortNo() != 20)
pfi.setSortNo(20);
} else if (ColumnName.equals("Name")) {
if (pfi.getSeqNo() != 10)
pfi.setSeqNo(10);
if (!pfi.isPrinted())
pfi.setIsPrinted(true);
if (!pfi.isOrderBy())
pfi.setIsOrderBy(true);
if (pfi.getSortNo() != 30)
pfi.setSortNo(30);
} else if (ColumnName.equals("Description")) {
if (pfi.getSeqNo() != 20)
pfi.setSeqNo(20);
if (!pfi.isPrinted())
pfi.setIsPrinted(true);
if (pfi.isOrderBy())
pfi.setIsOrderBy(false);
if (pfi.getSortNo() != 0)
pfi.setSortNo(0);
} else if (ColumnName.equals("AccountType")) {
if (pfi.getSeqNo() != 30)
pfi.setSeqNo(30);
if (!pfi.isPrinted())
pfi.setIsPrinted(true);
if (pfi.isOrderBy())
pfi.setIsOrderBy(false);
if (pfi.getSortNo() != 0)
pfi.setSortNo(0);
} else if (ColumnName.equalsIgnoreCase("Ax_Case")) {
if (pfi.getSeqNo() != 40)
pfi.setSeqNo(40);
if (!pfi.isPrinted())
pfi.setIsPrinted(true);
if (pfi.isOrderBy())
pfi.setIsOrderBy(false);
if (pfi.getSortNo() != 0)
pfi.setSortNo(0);
} else // Not Printed, No Sort
{
if (pfi.isPrinted())
pfi.setIsPrinted(false);
if (pfi.isOrderBy())
pfi.setIsOrderBy(false);
if (pfi.getSortNo() != 0)
pfi.setSortNo(0);
}
pfi.saveEx();
log.fine(pfi.toString());
}
// set translated to original
pf.setTranslation();
// Reload to pick up changed pfi
// no cache
pf = MPrintFormat.get(getCtx(), AD_PrintFormat_ID, true);
return pf;
}
use of org.compiere.print.MPrintFormatItem in project adempiere by adempiere.
the class PrintDataExcelExporter method getPDE.
private PrintDataElement getPDE(int row, int col) {
if (m_printData.getRowIndex() != row)
m_printData.setRowIndex(row);
//
MPrintFormatItem item = m_printFormat.getItem(col);
int AD_Column_ID = item.getAD_Column_ID();
Object obj = null;
if (AD_Column_ID > 0)
obj = m_printData.getNode(Integer.valueOf(AD_Column_ID));
if (obj != null && obj instanceof PrintDataElement) {
return (PrintDataElement) obj;
}
return null;
}
use of org.compiere.print.MPrintFormatItem in project adempiere by adempiere.
the class M_Element method afterSave.
/**
* After Save
* @param newRecord new
* @param success success
* @return success
*/
protected boolean afterSave(boolean newRecord, boolean success) {
// Update Columns, Fields, Parameters, Print Info
if (!newRecord) {
StringBuffer sql = new StringBuffer();
StringBuffer whereClause = new StringBuffer();
int no = 0;
if (is_ValueChanged(M_Element.COLUMNNAME_Name) || is_ValueChanged(M_Element.COLUMNNAME_Description) || is_ValueChanged(M_Element.COLUMNNAME_Help) || is_ValueChanged(M_Element.COLUMNNAME_ColumnName)) {
// Column
// sql = new StringBuffer("UPDATE AD_Column SET ColumnName=")
// .append(DB.TO_STRING(getColumnName()))
// .append(", Name=").append(DB.TO_STRING(getName()))
// .append(", Description=").append(DB.TO_STRING(getDescription()))
// .append(", Help=").append(DB.TO_STRING(getHelp()))
// .append(" WHERE AD_Element_ID=").append(get_ID());
// no = DB.executeUpdate(sql.toString(), get_TrxName());
// Use the Column model to trigger the after save and sync of the database.
whereClause = new StringBuffer(" AD_Element_ID=?");
List<MColumn> columns = new Query(getCtx(), MColumn.Table_Name, whereClause.toString(), get_TrxName()).setParameters(get_ID()).list();
for (MColumn column : columns) {
column.setColumnName(getColumnName());
column.setName(getName());
column.setDescription(getDescription());
column.setHelp(getHelp());
column.saveEx();
no++;
}
log.fine("afterSave - Columns updated #" + no);
// Parameter
// sql = new StringBuffer("UPDATE AD_Process_Para SET ColumnName=")
// .append(DB.TO_STRING(getColumnName()))
// .append(", Name=").append(DB.TO_STRING(getName()))
// .append(", Description=").append(DB.TO_STRING(getDescription()))
// .append(", Help=").append(DB.TO_STRING(getHelp()))
// .append(", AD_Element_ID=").append(get_ID())
// .append(" WHERE UPPER(ColumnName)=")
// .append(DB.TO_STRING(getColumnName().toUpperCase()))
// .append(" AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL");
// no = DB.executeUpdate(sql.toString(), get_TrxName());
whereClause = new StringBuffer("UPPER(ColumnName)=?").append(" AND IsCentrallyMaintained=? AND AD_Element_ID IS NULL");
List<MProcessPara> processParas = new Query(getCtx(), MProcessPara.Table_Name, whereClause.toString(), get_TrxName()).setParameters(DB.TO_STRING(getColumnName().toUpperCase()), true).list();
no = 0;
for (MProcessPara para : processParas) {
para.setColumnName(getColumnName());
para.setName(getName());
para.setDescription(getDescription());
para.setHelp(getHelp());
para.setAD_Element_ID(get_ID());
para.saveEx();
no++;
}
// sql = new StringBuffer("UPDATE AD_Process_Para SET ColumnName=")
// .append(DB.TO_STRING(getColumnName()))
// .append(", Name=").append(DB.TO_STRING(getName()))
// .append(", Description=").append(DB.TO_STRING(getDescription()))
// .append(", Help=").append(DB.TO_STRING(getHelp()))
// .append(" WHERE AD_Element_ID=").append(get_ID())
// .append(" AND IsCentrallyMaintained='Y'");
// no += DB.executeUpdate(sql.toString(), get_TrxName());
whereClause = new StringBuffer("AD_Element_ID=?").append(" AND IsCentrallyMaintained=?");
processParas = new Query(getCtx(), MProcessPara.Table_Name, whereClause.toString(), get_TrxName()).setParameters(get_ID(), true).list();
for (MProcessPara para : processParas) {
para.setColumnName(getColumnName());
para.setName(getName());
para.setDescription(getDescription());
para.setHelp(getHelp());
para.saveEx();
no++;
}
log.fine("Parameters updated #" + no);
}
if (is_ValueChanged(M_Element.COLUMNNAME_Name) || is_ValueChanged(M_Element.COLUMNNAME_Description) || is_ValueChanged(M_Element.COLUMNNAME_Help)) {
// Field
// sql = new StringBuffer("UPDATE AD_Field SET Name=")
// .append(DB.TO_STRING(getName()))
// .append(", Description=").append(DB.TO_STRING(getDescription()))
// .append(", Help=").append(DB.TO_STRING(getHelp()))
// .append(" WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=")
// .append(get_ID())
// .append(") AND IsCentrallyMaintained='Y'");
// no = DB.executeUpdate(sql.toString(), get_TrxName());
whereClause = new StringBuffer("AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=?").append(") AND IsCentrallyMaintained=?");
List<MField> fields = new Query(getCtx(), MField.Table_Name, whereClause.toString(), get_TrxName()).setParameters(get_ID(), true).list();
no = 0;
for (MField field : fields) {
field.setName(getName());
field.setDescription(getDescription());
field.setHelp(getHelp());
field.saveEx();
no++;
}
log.fine("Fields updated #" + no);
// Info Column - update Name, Description, Help - doesn't have IsCentrallyMaintained currently
// no = DB.executeUpdate(sql.toString(), get_TrxName());
// log.fine("InfoColumn updated #" + no);
}
if (is_ValueChanged(M_Element.COLUMNNAME_PrintName) || is_ValueChanged(M_Element.COLUMNNAME_Name)) {
// Print Info
// sql = new StringBuffer("UPDATE AD_PrintFormatItem pi SET PrintName=")
// .append(DB.TO_STRING(getPrintName()))
// .append(", Name=").append(DB.TO_STRING(getName()))
// .append(" WHERE IsCentrallyMaintained='Y'")
// .append(" AND EXISTS (SELECT * FROM AD_Column c ")
// .append("WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=")
// .append(get_ID()).append(")");
// no = DB.executeUpdate(sql.toString(), get_TrxName());
whereClause = new StringBuffer("AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=?").append(") AND IsCentrallyMaintained=?");
List<MPrintFormatItem> items = new Query(getCtx(), MPrintFormatItem.Table_Name, whereClause.toString(), get_TrxName()).setParameters(get_ID(), true).list();
no = 0;
for (MPrintFormatItem item : items) {
item.setPrintName(getPrintName());
item.setName(getName());
item.saveEx();
no++;
}
log.fine("PrintFormatItem updated #" + no);
}
}
return success;
}
Aggregations