View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

Reporting Server/Customizing Load Behavior

Contents


The data load scripts are responsible for loading data from the source database and inserting the data in the target database. In addition we support update scripts and refresh of materialized views as part of the load logic.

The load and update scripts use both a SQL script and accompanying logic developed in Java to execute the SQL script and process the results. For the logic in Java we use the following classes:

These classes are used when setting the script type to 'Standard Load', 'Standard Update' or 'Materialized View'. The standard implementations work fine for almost all cases. However, it is clearly possible that there are specialties which are best handled by changing the logic in Java. An example we have encountered is to read the product characteristics from the Openbravo product characteristic table and then updating the correct columns in the reporting product table. This could only be accomplished with a customized version of the data loader class.

Custom Class Implementation Details

Custom Load Class: extend the ExtendableDataLoader class

To implement a custom load class you can best extend the ExtendableDataLoader class.

The main method to override is the processRecord method but several other override points are provided:

  /**
   * Is called with one record of read data, the rs points to the current record. The subclass can use
   * the target connection to update/insert data. The subclass does not need to commit or close the 
   * connection, this is done in this class.
   */
  protected abstract void processRecord(ResultSet rs, Connection targetConnection);
 
  /**
   * Is called before the main read loop has started, default implementation does nothing
   */
  protected void beforeStart() {
  }
 
  /**
   * Is called after the main read loop has finished before the commit, default implementation does
   * nothing
   */
  protected void beforeCommit() {
  }

To get information on the current data load action (the sql script, the type etc,) you can call the 'getDataLoadStep' method which will return the DataLoadStep.

The ExtendableDataLoader class assumes that there is a SQL script defined which is executed in the source database. If data is loaded from other locations then it is best to override the doLoad method to customize the read behavior.

Transaction Handling

The ExtendableDataLoader class takes care of transaction handling for both the source and reporting database. The source connection is read-only. The reporting database connection is committed every so-many records (10000 is the default). The ExtendableDataLoader class also does the final commit and closes the connections.

Useful methods from the base class

Useful methods from the BaseUpdater class:

Custom Update Class

An update script is run only in the target database.

  /**
   * Is called before the update has started, default implementation does nothing
   */
  protected void beforeStart() {
    // to be overridden when needed
  }
 
  /**
   * Is called after the main read loop has finished before the commit, default implementation does
   * nothing
   */
  protected void beforeCommit() {
    // to be overridden when needed
  }
 
  /**
   * Executes the script from the data load step using a sql statement. Does not do commit or close
   * the connection.
   */
  protected void executeUpdate(String query, Connection conn) {
  ...
  }

The executeUpdate method does an executeUpdate call on the jdbc statement and can be overridden to do a custom update. This base class takes care of committing the connection.

Access to the source Openbravo database

Although this class has a connection to the reporting database, it is possible to get access to the source Openbravo database through the ConnectionProvider class. The Openbravo connection is read-only. In this case you need to close the connection yourselve.

Useful methods from the base class

Useful methods from the BaseUpdater class:

Defining the custom class in the load script

To use the custom load/update class create a new load script and select the script type 'Custom Load' or 'Custom Update'. Then enter the class name in the Custom Load Class Name. Note that for these custom classes the reporting table and sql script fields can be empty. This works fine as long as the custom implementation can handle this. Note that 'execute once' is supported for custom load/update classes.


Reporting custom class application dictionary.png

Retrieved from "http://wiki.openbravo.com/wiki/Reporting_Server/Customizing_Load_Behavior"

This page has been accessed 129 times. This page was last modified on 10 December 2019, at 19:28. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.