Class CacheRenderData

  • All Implemented Interfaces:
    RenderData

    public class CacheRenderData
    extends java.lang.Object
    implements RenderData
    This class is a RenderData source object running on i-net Clear Reports cache, for use with i-net Clear Reports Viewer. An RenderData object, such as an object of this class, is needed to create a new SwingReportView, for example. It uses the methods provided in Cache to get a cache object (Cache.getCache()), and then passes any data requests on to the cache.
    Since:
    7.0
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheRenderData​(java.lang.String url, PropertiesChecker checker, java.lang.Object req)
      Creates a RenderData source connection to i-net Clear Reports cache.
      CacheRenderData​(java.util.Properties props, PropertiesChecker checker, java.lang.Object req)
      Creates a RenderData source connection to i-net Clear Reports cache.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      RenderData getCopy()
      "Clones" this RenderData object with all its properties and returns the copy.
      protected EngineFactory getEngineFactory()
      returns the EngineFactory to pass to the Cache
      int getExportChunkCount​(java.util.Properties expProps)
      Returns the total number of export "chunks" for the report for the specified export format.
      byte[] getFontData​(int fontID)
      Returns the byte array of the embedded font at the specified fontId, which is encoded in the Viewer's protocol.
      byte[] getGroupTree()
      Returns the group tree which can be sent to the java viewer as a byte array.
      protected ReportCacheKey getKey​(java.util.Properties props)
      Create a key and start the rendering.
      byte[] getNextExportChunk()
      Returns the next chunk of the exported report if there is at least one more chunk available.
      int getPageCount()
      Returns the number of pages in the report.
      byte[] getPageData​(int page)
      Returns the binary data of one page for the Java Viewer.
      java.util.Properties getProperties()
      Returns the Properties object used by this RenderData object.
      java.lang.String getReportLocation()
      Returns the location of the report set by setReportLocation.
      java.lang.String getReportProperty​(java.lang.String propertyKey)
      Returns the chosen property value which has been set either via setReportProperty or otherwise.
      java.lang.String getReportTitle()
      Returns the manually set title of the report if there is one, that is, what would be typically displayed in a title bar, e.g.
      boolean isPageLimitExceeded()
      Check if the rendering of the report ran into a page limit.
      boolean isPromptOnRefresh()
      Returns the property "promptOnRefresh", that is, whether prompts are to be shown whenever new data is fetched from the server.
      byte[] refreshPageData​(int page)
      Enforces the whole report to be re-rendered on server side and returns the refreshed binary data of one page for the Java Viewer.
      void resetServerCacheTimeout()
      Notifies the server that the report with the currently set properties is still being viewed and therefore should not be removed from the cache yet if there is one.
      byte[] search​(java.lang.String phrase, int startPage, int flags)
      Searches the given phrase in the report, starting at a certain page and using the search options given in the flags.
      void setPromptOnRefresh​(boolean promptOnRefresh)
      Sets the property "promptOnRefresh", that is, whether prompts are to be shown whenever the report is refreshed, that is, whenever new data is fetched from the server.
      void setReportLocation​(java.lang.String name)
      Sets the location of the report which this RenderData is to obtain its data for.
      void setReportProperty​(java.lang.String key, java.lang.String value)
      Sets the given property for the report.
      void setReportTitle​(java.lang.String title)
      Sets the title of the report.
      void stop()
      Stops and cancels the rendering process if one is running.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CacheRenderData

        public CacheRenderData​(java.lang.String url,
                               PropertiesChecker checker,
                               java.lang.Object req)
        Creates a RenderData source connection to i-net Clear Reports cache.
        Parameters:
        url - The same data like setReportLocation.
        checker - an implementation of PropertiesChecker for validate the Properties. Can be null.
        req - The HTTP servlet request, either null or HttpServlet
        Since:
        7.0
        See Also:
        setReportLocation(String)
      • CacheRenderData

        public CacheRenderData​(java.util.Properties props,
                               PropertiesChecker checker,
                               java.lang.Object req)
        Creates a RenderData source connection to i-net Clear Reports cache.
        Parameters:
        props - A list of Properties.
        checker - an implementation of PropertiesChecker for validate the Properties. Can be null.
        req - The HTTP servlet request, either null or HttpServlet
        Since:
        7.0
    • Method Detail

      • setReportTitle

        public void setReportTitle​(java.lang.String title)
        Sets the title of the report. This title is what would be typically displayed in a title bar, e.g. "Employee Report 2005". Note that if this is not manually set, the title will be whatever the report has set as its title. If a title is set, it overrides the "actual" report title.
        Specified by:
        setReportTitle in interface RenderData
        Parameters:
        title - Title of the report as simple string.
      • getReportTitle

        public java.lang.String getReportTitle()
        Returns the manually set title of the report if there is one, that is, what would be typically displayed in a title bar, e.g. "Employee Report 2005". This will return null if no title was manually set.
        Specified by:
        getReportTitle in interface RenderData
        Returns:
        Title of report
      • setReportLocation

        public void setReportLocation​(java.lang.String name)
        Sets the location of the report which this RenderData is to obtain its data for. Any properties can be attached to the end using "=" for separating property name and value, and "&" for separating the various properties, e.g. "...&init=pdf&promptABC=test..." The location may not be null.
        Specified by:
        setReportLocation in interface RenderData
        Parameters:
        name - The location at which the report can be found. May not be null. *
      • getReportLocation

        public java.lang.String getReportLocation()
        Returns the location of the report set by setReportLocation. This will never be null. An uninitialized location will be returned as an empty string.
        Specified by:
        getReportLocation in interface RenderData
        Returns:
        Report Location (e.g URL)
        See Also:
        *
      • getPageData

        public byte[] getPageData​(int page)
                           throws ViewerException
        Returns the binary data of one page for the Java Viewer. Note that this method is thread-safe, that is, two or more threads concurrently calling this method and the other thread-safe methods in RenderData should cause no problems.
        Specified by:
        getPageData in interface RenderData
        Parameters:
        page - The number of the page. The first page is 1, the second is 2, ... .
        If the page number is not valid (usually meaning the page number is outside the page range), null can be returned.
        Returns:
        The binary data of the page for the Java viewer, or possibly null if page number is not valid.
        Throws:
        ViewerException - If an exception is returned from the server, it is wrapped in a ViewerException. Often this will be a com.inet.report.ReportException
        See Also:
        RenderData.getPageCount()
      • getPageCount

        public int getPageCount()
                         throws ViewerException
        Returns the number of pages in the report.
        This method blocks until the rendering process is finished. This is useful if you use i-net Clear Reports with external result sets or connections and you want to know when the rendering process is finished and you can close these external result sets or connections - once this method returns, the rendering process is finished. Note that this method is thread-safe, that is, two or more threads concurrently calling this method and the other thread-safe methods in RenderData should cause no problems.
        Specified by:
        getPageCount in interface RenderData
        Returns:
        number of pages (1-based)
        Throws:
        ViewerException - If there are rendering problems, etc.
        See Also:
        RenderData.getPageData(int)
      • isPageLimitExceeded

        public boolean isPageLimitExceeded()
        Check if the rendering of the report ran into a page limit. This means does not all possible pages exist.
        Specified by:
        isPageLimitExceeded in interface RenderData
        Returns:
        true, if there is a limit
      • getNextExportChunk

        public byte[] getNextExportChunk()
                                  throws ViewerException
        Returns the next chunk of the exported report if there is at least one more chunk available. It is required that getExportChunkCount(Properties) has been called once for this report.
        This method blocks until the rendering process of the requested chunk or the complete report is finished.
        Specified by:
        getNextExportChunk in interface RenderData
        Returns:
        Next chunk of the report, or null if the export is finished.
        Throws:
        ViewerException - If there are connection problems or other issues while fetching the data
        See Also:
        RenderData.getExportChunkCount(Properties)
      • getExportChunkCount

        public int getExportChunkCount​(java.util.Properties expProps)
                                throws ViewerException
        Returns the total number of export "chunks" for the report for the specified export format.
        A "chunk" is a unit of export data which can be retrieved using getNextExportChunk(). This method blocks until the rendering process is finished on the server. Note that this method is thread-safe, that is, two or more threads concurrently calling this method and the other thread-safe methods in RenderData should cause no problems.
        In case of gzip compression, the number of chunks can not be determined and "0" is returned. The chunks can be retrieved in a loop until getNextExportChunk() returns NULL.
        Specified by:
        getExportChunkCount in interface RenderData
        Parameters:
        expProps - Properties to be appended to the current report properties for this export. The properties should contain at least the export format with the key "export_fmt". The following formats are valid:
        "pdf" - pdf file
        "rtf" - rtf file
        "xls" - xls file
        "csv" - csv file
        "ps" - ps file
        "xml" -xml file
        "htm" - html files, The file name is the base filename, because there are more files with links.
        For a complete list of report URL properties see the documentation.
        Returns:
        Total number of export "chunks" (i.e. units) which can be fetched using getNextExportChunk()
        Throws:
        ViewerException - If there are connection problems or other issues while fetching the data
        See Also:
        RenderData.getNextExportChunk(), RenderData.getProperties()
      • getGroupTree

        public byte[] getGroupTree()
                            throws ViewerException
        Returns the group tree which can be sent to the java viewer as a byte array. Note that this method is thread-safe, that is, two or more threads concurrently calling this method and the other thread-safe methods in RenderData should cause no problems.
        Specified by:
        getGroupTree in interface RenderData
        Returns:
        byte[] Group Tree as byte array, encoded by i-net Clear Reports.
        Throws:
        ViewerException - If there are connection problems or other issues while fetching the data
      • refreshPageData

        public byte[] refreshPageData​(int page)
                               throws ViewerException
        Enforces the whole report to be re-rendered on server side and returns the refreshed binary data of one page for the Java Viewer. This page is rendered anew rather than possibly taking a cached version.
        Specified by:
        refreshPageData in interface RenderData
        Parameters:
        page - The number of the page. The first page is 1, the second is 2, ... . If the page number is bigger than the page count the data from the last page will be returned.
        Returns:
        the binary data for the Java Viewer
        Throws:
        ViewerException - If there are connection problems or other issues while fetching the data
        See Also:
        RenderData.getPageCount()
      • getReportProperty

        public java.lang.String getReportProperty​(java.lang.String propertyKey)
        Returns the chosen property value which has been set either via setReportProperty or otherwise.
        Specified by:
        getReportProperty in interface RenderData
        Parameters:
        propertyKey - Name of property to get value for
        Returns:
        Value of property with the given name
      • getProperties

        public java.util.Properties getProperties()
        Returns the Properties object used by this RenderData object. Note this is NOT a clone but rather the exact object used by RenderData - any changes made to this Properties object will influence the RenderData. See https://www.inetsoftware.de/documentation/clear-reports/plugins/clear-reports/documentation/en/report-url-parameters for a list of possible properties to set here and what they mean.

        Note also that any key values should be set in lower case. This Properties object will never be null, at most it will be empty.

        Specified by:
        getProperties in interface RenderData
        Returns:
        Properties object used by RenderData, never null
      • setPromptOnRefresh

        public void setPromptOnRefresh​(boolean promptOnRefresh)
        Sets the property "promptOnRefresh", that is, whether prompts are to be shown whenever the report is refreshed, that is, whenever new data is fetched from the server.
        Specified by:
        setPromptOnRefresh in interface RenderData
        Parameters:
        promptOnRefresh - Value to set for this property
      • isPromptOnRefresh

        public boolean isPromptOnRefresh()
        Returns the property "promptOnRefresh", that is, whether prompts are to be shown whenever new data is fetched from the server.
        Specified by:
        isPromptOnRefresh in interface RenderData
        Returns:
        The property "promptOnRefresh"
      • getCopy

        public RenderData getCopy()
        "Clones" this RenderData object with all its properties and returns the copy. Useful for deriving from existing RenderData objects by copying them and adding or changing properties. This method is called by the viewer for drilling down, for example - the drilldown property is set on the copy while all other properties remain the same, and the copy is used to open a new report view.
        Specified by:
        getCopy in interface RenderData
        Returns:
        A cloned copy of this RenderData object with all its properties.
        See Also:
        ReportViewer.addNewReportView(RenderData), RenderData.getProperties()
      • stop

        public void stop()
        Stops and cancels the rendering process if one is running. This command ends up being passed through to i-net Clear Reports rendering engine and running Engine.stop.
        Specified by:
        stop in interface RenderData
      • search

        public byte[] search​(java.lang.String phrase,
                             int startPage,
                             int flags)
        Searches the given phrase in the report, starting at a certain page and using the search options given in the flags. These flags are:

        WHOLE_WORD : search only the word in its entirety, not parts of words.
        CASE_SENSITIVE : observe upper and lower cases in the search, that is "Search" != "search"
        REGULAR_EXPRESSION : The search phrase is to be handled as a regular expression (using Java's Regex methods for the search).

        Desired flags should be connected by the OR operator "|". So, for example, to search with the flags WHOLE_WORD and CASE_SENSITIVE, simply use WHOLE_WORD | CASE_SENSITIVE as the flags option.

        Note that phrases going over more than one page will not be found, nor will text parts with formatting inside the word itself, such as this word. Note that this method is thread-safe, that is, two or more threads concurrently calling this method and the other thread-safe methods in RenderData should cause no problems.

        Specified by:
        search in interface RenderData
        Parameters:
        phrase - Word or phrase to search. Should be a regular expression if this flag is set.
        startPage - Page to start searching on (1-based)
        flags - Desired search options (see above)
        Returns:
        Search result by the server, encoded in the i-net Clear Reports protocol.
        See Also:
        RenderData.WHOLE_WORD, RenderData.CASE_SENSITIVE, RenderData.REGULAR_EXPRESSION
      • getFontData

        public byte[] getFontData​(int fontID)
        Returns the byte array of the embedded font at the specified fontId, which is encoded in the Viewer's protocol. You need not and should not call this method yourself - rather the Viewer will call this method on its own when an embedded font needs to be fetched for the report.

        The fontID is 1-based. null will be returned if there are no fonts embedded for the report of this Engine. If fontID is greater than the number of embedded fonts available it will return the last font available. This method is the mirror method to com.inet.report.Engine.getFontData(int), so implementations can either call that if an engine is available, or a running i-net Clear Reports server also returns the font data with an HTTP request of the form "http://server:9000/?report=report.rpt&export_fmt=font&page=FONTID&cmd=get_pg" where FONTID is replaced with the given font ID. Note that this method is thread-safe, that is, two or more threads concurrently calling this method and the other thread-safe methods in RenderData should cause no problems.

        Specified by:
        getFontData in interface RenderData
        Parameters:
        fontID - ID of font as specified in the i-net Clear Reports protocol
        Returns:
        Partial or whole font with the ID, and with the most current version of this font known to the server.
      • resetServerCacheTimeout

        public void resetServerCacheTimeout()
        Notifies the server that the report with the currently set properties is still being viewed and therefore should not be removed from the cache yet if there is one. This method does NOT cause the report to be re-rendered under any circumstance, rather it resets the cache timeout on the server if there is one.

        This method will be called in regular intervals (default is every 5 minutes) by its corresponding ReportView(s).

        Specified by:
        resetServerCacheTimeout in interface RenderData