com.ihr.xbrl.dataloader.target
Class SQLDriver

java.lang.Object
  extended by com.ihr.xbrl.dataloader.target.SQLDriver
All Implemented Interfaces:
XBRLLoaderInterface

public class SQLDriver
extends java.lang.Object
implements XBRLLoaderInterface

This driver loads data in an SQL repository responding to load events generated by the loader engine.

The configuration file is read when init() method is called.

The configuration file provides initial data to open a connection to the database.

The connection to the database is created at the time the loader calls createNewResult(Processor) method.

A new transaction is started when the loader calls startOfDocument(XBRLInstance)

The configuration file must have one SQL statement per identifier. The SQL statement may have parts that will be replaced by the result of XPath expressions. The XPath expressions will be evaluated at the time the event is produced and in order to complete the SQL expression. The XPath expression will contain some environmental variables that facilitates access to parts of the DTS.

The transaction is closed when the loader calls endOfDocument()

Author:
Ignacio

Nested Class Summary
static class SQLDriver.SQLIdentifier
          This class is the object that contains the identifier and the SQL text with XPath sentences to parameterize the final SQL statement
static class SQLDriver.SQLTransformationResult
          This is the result of the execution of the SQL procedures
 
Constructor Summary
SQLDriver()
           
 
Method Summary
 XBRLTransformationResult createNewResult(net.sf.saxon.s9api.Processor configuration)
          Creates a new document container.
 void endOfDocument()
          Called by the transformation processor to indicate the end of a document processing Usually a document footer is produced.
 java.net.URI getConfigFile()
          Returns back the URI of the configuration file
 void init()
          This method is called by the loader just after object has been created and if a configuration file is set (which is an optional step only if configuration file is indicated as a parameter) This method should read the configuration file and set values for constants and things like that.
 void processContexts(java.util.Iterator<XBRLContext> contexts)
          Called by the transformation processor to provide the contexts for the data that will be found later during the processing of facts the default process updates the content of some variables. or calculates number of columns, rows.
 void processFact(java.lang.String identifier, XBRLFact fact)
          Called by the processor to inform about a new fact that requires processing.
 void setConfigFile(java.net.URI uriConfigFile)
          This method is called by the loader when a new loader is just created and for each one of the drivers that exist on the loader configuration file and only if the driver has a parameter indicating the URL of the configuration file Next call is XBRLLoaderInterface.init()
 void startOfDocument(XBRLInstance instance)
          Called by the transformation processor to indicate the start of a new document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLDriver

public SQLDriver()
Method Detail

init

public void init()
          throws LoaderConfigurationFileException
Description copied from interface: XBRLLoaderInterface
This method is called by the loader just after object has been created and if a configuration file is set (which is an optional step only if configuration file is indicated as a parameter) This method should read the configuration file and set values for constants and things like that. Next call is XBRLLoaderInterface.createNewResult(Processor)

Specified by:
init in interface XBRLLoaderInterface
Throws:
LoaderConfigurationFileException

setConfigFile

public void setConfigFile(java.net.URI uriConfigFile)
Description copied from interface: XBRLLoaderInterface
This method is called by the loader when a new loader is just created and for each one of the drivers that exist on the loader configuration file and only if the driver has a parameter indicating the URL of the configuration file Next call is XBRLLoaderInterface.init()

Specified by:
setConfigFile in interface XBRLLoaderInterface

createNewResult

public XBRLTransformationResult createNewResult(net.sf.saxon.s9api.Processor configuration)
                                         throws FactHandlerException
Description copied from interface: XBRLLoaderInterface
Creates a new document container. This method is the first one called when a new instance document requires to be processed. This method can be used to open connections to the target repository. Next call is XBRLLoaderInterface.startOfDocument(XBRLInstance)

Specified by:
createNewResult in interface XBRLLoaderInterface
Parameters:
configuration - Saxon s9api Processor object
Returns:
XBRLTransformationResult an object that implements the XBRLTransformationResult interface.
Throws:
FactHandlerException - if anything goes wrong.

startOfDocument

public void startOfDocument(XBRLInstance instance)
                     throws FactHandlerException
Description copied from interface: XBRLLoaderInterface
Called by the transformation processor to indicate the start of a new document. Usually a document header is produced. A new template document is initialized or a transaction is created. Next call is XBRLLoaderInterface.processContexts(Iterator)

Specified by:
startOfDocument in interface XBRLLoaderInterface
Throws:
FactHandlerException

processContexts

public void processContexts(java.util.Iterator<XBRLContext> contexts)
Description copied from interface: XBRLLoaderInterface
Called by the transformation processor to provide the contexts for the data that will be found later during the processing of facts the default process updates the content of some variables. or calculates number of columns, rows. Next call is XBRLLoaderInterface.processFact(String, XBRLFact) for facts that passes the filters established by the loader engine and are the true loading events.

Specified by:
processContexts in interface XBRLLoaderInterface
Parameters:
contexts - Iterator<XBRLContext>

processFact

public void processFact(java.lang.String identifier,
                        XBRLFact fact)
                 throws FactHandlerException
Description copied from interface: XBRLLoaderInterface
Called by the processor to inform about a new fact that requires processing. This is where the real loading event is handled by the driver. Next call is XBRLLoaderInterface.endOfDocument() when the instance document is finished and no more events needs to be generated

Specified by:
processFact in interface XBRLLoaderInterface
Parameters:
identifier - as String which is the identifier code in the loader configuration file.
fact - XBRLFact the loaded fact
Throws:
FactHandlerException - if something goes wrong.

endOfDocument

public void endOfDocument()
                   throws FactHandlerException
Description copied from interface: XBRLLoaderInterface
Called by the transformation processor to indicate the end of a document processing Usually a document footer is produced. Or the transaction is committed. There is no a next call.

Specified by:
endOfDocument in interface XBRLLoaderInterface
Throws:
FactHandlerException - if something goes wrong

getConfigFile

public java.net.URI getConfigFile()
Description copied from interface: XBRLLoaderInterface
Returns back the URI of the configuration file

Specified by:
getConfigFile in interface XBRLLoaderInterface
Returns:
URI


Copyright 2006-2009 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa