Class ReportEngine

java.lang.Object
org.compiere.print.ReportEngine
All Implemented Interfaces:
PrintServiceAttributeListener

public class ReportEngine extends Object implements PrintServiceAttributeListener
Report Engine.
For a given PrintFormat, create a Report.

Change log:

  • 2007-02-12 - teo_sarca - [ 1658127 ] Select charset encoding on import
  • 2007-02-10 - teo_sarca - [ 1652660 ] Save XML,HTML,CSV should have utf8 charset
  • 2009-02-06 - globalqss - [ 2574162 ] Priority to choose invoice print format not working
  • 2009-07-10 - trifonnt - [ 2819637 ] Wrong print format on non completed order
Version:
$Id: ReportEngine.java,v 1.4 2006/10/08 06:52:51 comdivision Exp $
Author:
Jorg Janke, Teo Sarca, www.arhipac.ro
  • BF [ 2828300 ] Error when printformat table differs from DOC_TABLES https://sourceforge.net/p/adempiere/bugs/1995/
  • BF [ 2828886 ] Problem with reports from temporary tables https://sourceforge.net/p/adempiere/bugs/2000/ FR 2872010 - Dunning Run for a complete Dunning (not just level) - Developer: Carlos Ruiz - globalqss - Sponsor: Metas
    • Field Details

    • Constructor Details

      • ReportEngine

        public ReportEngine(Properties ctx, MPrintFormat pf, MQuery query, PrintInfo info)
        Constructor
        Parameters:
        ctx - context
        pf - Print Format
        query - Optional Query
        info - print info
      • ReportEngine

        public ReportEngine(Properties ctx, MPrintFormat pf, MQuery query, PrintInfo info, boolean isSummary)
        Create report engine with summary and null transaction
        Parameters:
        ctx -
        pf -
        query -
        info -
        isSummary -
      • ReportEngine

        public ReportEngine(Properties ctx, MPrintFormat pf, MQuery query, PrintInfo info, String trxName)
        Create report engine with summary = false
        Parameters:
        ctx -
        pf -
        query -
        info -
        trxName -
      • ReportEngine

        public ReportEngine(Properties ctx, MPrintFormat pf, MQuery query, PrintInfo info, boolean isSummary, String trxName)
        Constructor
        Parameters:
        ctx - context
        pf - Print Format
        query - Optional Query
        info - print info
        isSummary -
        trxName -
      • ReportEngine

        public ReportEngine(Properties ctx, MPrintFormat pf, MQuery query, PrintInfo info, String trxName, int windowNo)
        Set report engine with summary = false
        Parameters:
        ctx -
        pf -
        query -
        info -
        trxName -
        windowNo -
      • ReportEngine

        public ReportEngine(Properties ctx, MPrintFormat pf, MQuery query, PrintInfo info, boolean isSummary, String trxName, int windowNo)
        Constructor
        Parameters:
        ctx - context
        pf - Print Format
        query - Optional Query
        info - print info
        isSummary -
        trxName -
        windowNo -
    • Method Details

      • addEventListener

        public void addEventListener(IReportEngineEventListener listener)
        Add report engine event listener
        Parameters:
        listener -
      • removeEventListener

        public boolean removeEventListener(IReportEngineEventListener listener)
        Remove report engine event listener
        Parameters:
        listener -
        Returns:
        true if found and remove
      • setPrintFormat

        public void setPrintFormat(MPrintFormat pf)
        Set PrintFormat. If Layout was created, re-create layout
        Parameters:
        pf - print format
      • setQuery

        public void setQuery(MQuery query)
        Set Query and load PrintData.
        If Layout was created, re-create layout.
        Fire onQueryChanged event.
        Parameters:
        query - query
      • getQuery

        public MQuery getQuery()
        Get Query
        Returns:
        query
      • getPrintData

        public PrintData getPrintData()
        Get PrintData
        Returns:
        print data
      • setPrintData

        public void setPrintData(PrintData printData)
        Set PrintData
        Parameters:
        printData - printData
      • getLayout

        public LayoutEngine getLayout()
        Get Layout Engine
        Returns:
        Layout engine
      • initName

        public void initName()
        Initialize Report Name
      • getName

        public String getName()
        Get PrintFormat (Report) Name
        Returns:
        name
      • getPrintFormat

        public MPrintFormat getPrintFormat()
        Get PrintFormat
        Returns:
        print format
      • getPrintInfo

        public PrintInfo getPrintInfo()
        Get Print Info
        Returns:
        info
      • getCtx

        public Properties getCtx()
        Get PrintLayout (Report) Context
        Returns:
        context
      • getRowCount

        public int getRowCount()
        Get Row Count
        Returns:
        row count
      • getColumnCount

        public int getColumnCount()
        Get Column Count
        Returns:
        column count
      • print

        public void print()
        Print Report. Issue print job to printer.
      • attributeUpdate

        public void attributeUpdate(PrintServiceAttributeEvent psae)
        Print Service Attribute Listener.
        Specified by:
        attributeUpdate in interface PrintServiceAttributeListener
        Parameters:
        psae - event
      • pageSetupDialog

        public void pageSetupDialog()
        Show Print Dialog and Set Paper.
        Optionally re-calculate layout.
      • setPrinterName

        public void setPrinterName(String printerName)
        Set Printer (name)
        Parameters:
        printerName - valid printer name
      • getPrinterName

        public String getPrinterName()
        Get Printer (name)
        Returns:
        printer name
      • createHTML

        public boolean createHTML(File file, boolean onlyTable, Language language)
        Create HTML File
        Parameters:
        file - file
        onlyTable - if false create complete HTML document
        language - optional language - if null the default language is used to format numbers/dates
        Returns:
        true if success
      • createHTML

        public boolean createHTML(File file, boolean onlyTable, Language language, IHTMLExtension extension)
        Create HTML File
        Parameters:
        file - file
        onlyTable - if false create complete HTML document
        language - optional language - if null the default language is used to format numbers/dates
        extension - optional extension for html output
        Returns:
        true if success
      • createHTML

        public boolean createHTML(Writer writer, boolean onlyTable, Language language)
        Write HTML to writer
        Parameters:
        writer - writer
        onlyTable - if false create complete HTML document
        language - optional language - if null numbers/dates are not formatted
        Returns:
        true if success
      • createHTML

        public boolean createHTML(Writer writer, boolean onlyTable, Language language, IHTMLExtension extension)
        Write HTML to writer with isExport = false
        Parameters:
        writer - writer
        onlyTable - if false create complete HTML document
        language - optional language - if null numbers/dates are not formatted
        extension - optional extension for html output
        Returns:
        true if success
      • createHTML

        public boolean createHTML(Writer writer, boolean onlyTable, Language language, IHTMLExtension extension, boolean isExport)
        Write HTML to writer
        Parameters:
        writer - writer
        onlyTable - if false create complete HTML document
        language - optional language - if null numbers/dates are not formatted
        extension - optional extension for html output
        isExport - when isExport = true will don't embed resource dependent zk framework
        Returns:
        true if success
      • getIdentifier

        public String getIdentifier(MTable mTable, String tableName, int recordID)
        Get record identifier string
        Parameters:
        mTable -
        tableName -
        recordID -
        Returns:
        String identifier
      • createCSV

        public boolean createCSV(File file, char delimiter, Language language)
        Create delimited text file
        Parameters:
        file - file
        delimiter - delimiter, e.g. comma, tab
        language - translation language
        Returns:
        true if success
      • createCSV

        public boolean createCSV(Writer writer, char delimiter, Language language)
        Write delimited content to writer
        Parameters:
        writer - writer
        delimiter - delimiter, e.g. comma, tab
        language - translation language
        Returns:
        true if success
      • createXML

        public boolean createXML(File file)
        Create XML File
        Parameters:
        file - file
        Returns:
        true if success
      • createXML

        public boolean createXML(Writer writer)
        Write XML to writer
        Parameters:
        writer - writer
        Returns:
        true if success
      • getPDF

        public File getPDF()
        Create PDF file (created as temporary file).
        Returns:
        PDF file
      • getPDF

        public File getPDF(File file)
        Create PDF file.
        Parameters:
        file - optional, null to use system generated temporary file
        Returns:
        PDF file
      • getHTML

        public File getHTML()
        Create HTML file (created as temporary file).
        Returns:
        HTML file
      • getHTML

        public File getHTML(File file)
        Create HTML file.
        Parameters:
        file - optional, null to use system generated temporary file
        Returns:
        HTML file
      • getCSV

        public File getCSV()
        Create CSV file (created as temporary file).
        Returns:
        CSV file
      • getCSV

        public File getCSV(File file)
        Create CSV file.
        Parameters:
        file - optional, null to use system generated temporary file
        Returns:
        CSV file
      • getXLS

        public File getXLS()
        Create XLS file (created as temporary file).
        Returns:
        XLS file
      • getXLS

        public File getXLS(File file)
        Create XLS file.
        Parameters:
        file - optional, null to use system generated temporary file
        Returns:
        XLS file
      • getXLSX

        public File getXLSX()
        Create XLSX file (created as temporary file).
        Returns:
        XLSX file
      • getXLSX

        public File getXLSX(File file)
        Create XLSX file.
        Parameters:
        file - optional, null to use system generated temporary file
        Returns:
        XLSX file
      • createPDF

        public boolean createPDF(File file)
        Create PDF File
        Parameters:
        file - optional, null to use system generated temporary file
        Returns:
        true if success
      • createPDFData

        public byte[] createPDFData()
        Create PDF as Data array
        Returns:
        pdf data
      • createPS

        public boolean createPS(File file)
        Create PostScript File
        Parameters:
        file - output file
        Returns:
        true if success
      • createPS

        public boolean createPS(OutputStream os)
        Write PostScript to writer
        Parameters:
        os - output stream
        Returns:
        true if success
      • createXLS

        public void createXLS(File outFile, Language language) throws Exception
        Create Excel file
        Parameters:
        outFile - output file
        language -
        Throws:
        Exception - if error
      • createXLSX

        public void createXLSX(File outFile, Language language) throws Exception
        Create ExcelX file
        Parameters:
        outFile - output file
        language -
        Throws:
        Exception - if error
      • get

        public static ReportEngine get(Properties ctx, ProcessInfo pi)
        Get Report Engine for process info
        Parameters:
        ctx - context
        pi - process info with AD_PInstance_ID
        Returns:
        report engine or null
      • get

        public static ReportEngine get(Properties ctx, ProcessInfo pi, int windowNo)
        Get Report Engine for process info
        Parameters:
        ctx - context
        pi - process info with AD_PInstance_ID
        windowNo - Window No
        Returns:
        report engine or null
      • get

        public static ReportEngine get(Properties ctx, int type, int Record_ID)
        Get Document Print Engine for Document Type.
        Parameters:
        ctx - context
        type - document type
        Record_ID - id
        Returns:
        Report Engine or null
      • get

        public static ReportEngine get(Properties ctx, int type, int Record_ID, int windowNo)
        Get Document Print Engine for Document Type.
        Parameters:
        ctx - context
        type - document type
        Record_ID - id
        Returns:
        Report Engine or null
      • get

        public static ReportEngine get(Properties ctx, int type, int Record_ID, String trxName)
        Get Document Print Engine for Document Type.
        Parameters:
        ctx - context
        type - document type
        Record_ID - id
        trxName -
        Returns:
        Report Engine or null
      • get

        public static ReportEngine get(Properties ctx, int type, int Record_ID, String trxName, int windowNo)
        Get Document Print Engine for Document Type.
        Parameters:
        ctx - context
        type - document type
        Record_ID - id
        trxName -
        windowNo -
        Returns:
        Report Engine or null
      • printConfirm

        public static void printConfirm(int type, int Record_ID)
        Print Confirm.
        Update Date Printed.
        Parameters:
        type - report engine document type (ORDER, SHIPMENT, etc)
        Record_ID - record id
      • setWhereExtended

        public void setWhereExtended(String whereExtended)
        Set extended where clause
        Parameters:
        whereExtended -
      • getWhereExtended

        public String getWhereExtended()
        Get extended where clause
        Returns:
        extended where clause
      • setWindowNo

        public void setWindowNo(int windowNo)
        Set windowNo of the report to parse the context
      • getWindowNo

        public int getWindowNo()
        Get window no
        Returns:
        window no
      • setSummary

        public void setSummary(boolean summary)
        Set summary report
        Parameters:
        summary -
      • isSummary

        public boolean isSummary()
        Is summary report
        Returns:
        true if it is a summary report
      • setLanguageID

        public void setLanguageID(int languageID)
        Set language id
        Parameters:
        languageID -
      • getLanguageID

        public int getLanguageID()
        Get language id
        Returns:
        language id
      • setReportType

        public void setReportType(String type)
        Set report output type
        Parameters:
        type - output type (pdf, html, etc)
      • getReportType

        public String getReportType()
        Get report output type
        Returns:
        report output type (pdf, html, etc)
      • isReplaceTabContent

        public boolean isReplaceTabContent()
        Determines, if current tab content should be replaced, or a new tab should be opened
        Returns:
        true if it is to replace content of current active tab
      • setIsReplaceTabContent

        public void setIsReplaceTabContent(boolean m_isReplaceTabContent)
        Sets, if current tab content should be replaced, or a new tab should be opened
        Parameters:
        m_isReplaceTabContent -
      • getReportEngineType

        public static int getReportEngineType(int tableID)
        Get Report Engine Type from Table_ID
        Parameters:
        tableID -
        Returns:
        Report Engine Type -1 if Report Engine Type was not found
      • setDefaultReportTypeToPInstance

        public static void setDefaultReportTypeToPInstance(Properties ctx, MPInstance instance, int printFormatID)
        Update AD_PInstance with default report output type (if it is not set)
        Parameters:
        ctx -
        instance -
        printFormatID -
      • setProcessInfo

        public void setProcessInfo(ProcessInfo pi)
        Parameters:
        pi -
      • getProcessInfo

        public ProcessInfo getProcessInfo()
        Returns:
        ProcessInfo
      • isDisplayPFItem

        public static boolean isDisplayPFItem(PrintData printData, MPrintFormatItem item)
        Evaluate display logic of a print format item
        Parameters:
        printData - data for display logic evaluation
        item - print format item
        Returns:
        true if item has no display logic or display logic evaluate to true