com.ihr.xbrl.store
Class StorageService

java.lang.Object
  extended by com.ihr.xbrl.database.common.XBRLDatabaseAccessApp
      extended by com.ihr.xbrl.store.StorageService
All Implemented Interfaces:
HasEnableDisableOpenMenus, StorageEventListener
Direct Known Subclasses:
RSS_Storage_SEC

public class StorageService
extends XBRLDatabaseAccessApp
implements HasEnableDisableOpenMenus, StorageEventListener

This class is a storage service for XBRL documents to the XBRL Database.

The idea is that a job to store a DTS is created by an external application and submitted to this service. The service creates a new thread in order to deal with the database.

This class contains handlers for all required interfaces during the storage phase

Author:
Ignacio

Field Summary
static int CREATED_STATUS
           
static int ERROR_STATUS
           
static int RUNNING_STATUS
           
static int STORED_STATUS
           
static int UNKNOWN_STATUS
           
 
Constructor Summary
StorageService(DatabaseManagerBase dbm, RegisterExtraClasses[] extra, java.util.Properties props, boolean hasGUI)
          It must be public because of the way it should be initialized due to the HasURIResolverParameter interface.
StorageService(RegisterExtraClasses[] extra, java.util.Properties props, boolean hasGUI)
          It must be public because of the way it should be initialized due to the HasURIResolverParameter interface.
 
Method Summary
 void clear()
          Releases memory in the caches reserved by the surrounding processors.
 void disableOpen()
          Called when menus has to be set to "disabled" state
 void documentStoredEvent(StorageEvent evt)
           
 void doStoreDTS(java.lang.String instanceUriOnDatabase, XBRLDocument document, org.hibernate.Session parameter, boolean inNewThread, boolean bForUpdate, org.apache.log4j.Level logLevel, StorageEventListener[] listeners)
          Starts the storage of a DTS into the database in an unattended new thread.
 void doStoreDTS(XBRLDocument document, org.hibernate.Session parameter, boolean inNewThread, boolean bForUpdate, org.apache.log4j.Level logLevel, StorageEventListener[] listeners)
          Starts the storage of a DTS into the database in an unattended new thread.
 void enableOpen()
          Called when menus has to be set to "enables" state
 java.lang.String getLastMessage(StoreXBRLThread th)
           
 int getPercentage(StoreXBRLThread th)
           
static StorageService getService(RegisterExtraClasses[] extra, java.util.Properties props, boolean hasGUI)
          Obtains the instance of the static service class that manages storage of information into the XBRL database.
 java.lang.String getStackTrace(StoreXBRLThread th)
           
 int getStatus(StoreXBRLThread th)
           
 java.util.Collection<StoreXBRLThread> getStorageThreads()
          Access to the collection of active threads.
 java.lang.String getTooltipMessage(StoreXBRLThread th)
           
 boolean isStored(java.net.URI uri, org.hibernate.Session dbSession)
          Returns true if the document with URI is already stored in the database
 
Methods inherited from class com.ihr.xbrl.database.common.XBRLDatabaseAccessApp
getDbUtil, getStatus, showDbSettings
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATED_STATUS

public static final int CREATED_STATUS
See Also:
Constant Field Values

RUNNING_STATUS

public static final int RUNNING_STATUS
See Also:
Constant Field Values

STORED_STATUS

public static final int STORED_STATUS
See Also:
Constant Field Values

ERROR_STATUS

public static final int ERROR_STATUS
See Also:
Constant Field Values

UNKNOWN_STATUS

public static final int UNKNOWN_STATUS
See Also:
Constant Field Values
Constructor Detail

StorageService

public StorageService(RegisterExtraClasses[] extra,
                      java.util.Properties props,
                      boolean hasGUI)
It must be public because of the way it should be initialized due to the HasURIResolverParameter interface.

Parameters:
extra - is an array of RegisterExtraClasses objects
props - additional Properties object for the connection to the database
hasGUI - this is true if the service can open a window to the end user. false otherwise.
See Also:
RegisterExtraClasses

StorageService

public StorageService(DatabaseManagerBase dbm,
                      RegisterExtraClasses[] extra,
                      java.util.Properties props,
                      boolean hasGUI)
It must be public because of the way it should be initialized due to the HasURIResolverParameter interface.

Parameters:
dbm - the database manager base to use with alternate configuration to connect to the database
extra - is an array of RegisterExtraClasses objects
props - additional Properties object for the connection to the database and to the pojo generarion process
hasGUI - this is true if the service can open a window to the end user. false otherwise.
See Also:
RegisterExtraClasses
Method Detail

getService

public static StorageService getService(RegisterExtraClasses[] extra,
                                        java.util.Properties props,
                                        boolean hasGUI)
Obtains the instance of the static service class that manages storage of information into the XBRL database.

The parameters are optional and both can be null.

Parameters:
extra - array of RegisterExtraClasses instances. The RegisterExtraClasses interface allows for extending the database model for additional objects
props - extra properties that will be added to the connection to the database and to the pojo generarion process
hasGUI - this is true if the service can open a window to the end user. false otherwise.
Returns:
the StorageSerice instance. The first time this method is called the service will be initialized with the supplied parameters. on subsequent calls the parameters are ignored. Note the constructor of the StorageService is public this allows you applications to configure multiple storage services if this is needed.
See Also:
RegisterExtraClasses

doStoreDTS

public void doStoreDTS(XBRLDocument document,
                       org.hibernate.Session parameter,
                       boolean inNewThread,
                       boolean bForUpdate,
                       org.apache.log4j.Level logLevel,
                       StorageEventListener[] listeners)
Starts the storage of a DTS into the database in an unattended new thread. The process can be interrogated doing calls to this object.

NOTE: The second parameter is the database session. It MUST be configured with Flush.COMMIT in order to work properly. typically you would do:

        Session session = StorageService.getService(null,null).getDbUtil().getSessionFactory(null).openSession();
        session.setFlushMode(FlushMode.COMMIT);
        StorageService.getService(null,null).doStoreDTS(instance,session,true,false);
 

Parameters:
document - XBRLDocument to be stored
parameter - the database session already opened
inNewThread - if this argument is false, the storage will not create a new thread
bForUpdate - if this parameter is true and the document already exists in the database, the document content will be updated. (only for XBRL reports)
logLevel -
listener - array of listeners that will receive a copy of the StorageEvent. null means no listeners will receive a copy of the event.

doStoreDTS

public void doStoreDTS(java.lang.String instanceUriOnDatabase,
                       XBRLDocument document,
                       org.hibernate.Session parameter,
                       boolean inNewThread,
                       boolean bForUpdate,
                       org.apache.log4j.Level logLevel,
                       StorageEventListener[] listeners)
Starts the storage of a DTS into the database in an unattended new thread. The process can be interrogated doing calls to this object.

NOTE: The second parameter is the database session. It MUST be configured with Flush.COMMIT in order to work properly. typically you would do:

        Session session = StorageService.getService(null,null).getDbUtil().getSessionFactory(null).openSession();
        session.setFlushMode(FlushMode.COMMIT);
        StorageService.getService(null,null).doStoreDTS(instance,session,true,false);
 

Parameters:
instanceUriOnDatabase - this is the URI of the instance document in the database. Also, the URI will be used as base uri for transformation of locally referenced taxonomies and linkbases
document - XBRLDocument to be stored
parameter - the database session already opened
inNewThread - if this argument is false, the storage will not create a new thread
bForUpdate - if this parameter is true and the document already exists in the database, the document content will be updated. (only for XBRL reports)
logLevel -
listener - array of listeners that will receive a copy of the StorageEvent. null means no listeners will receive a copy of the event.

clear

public void clear()
Releases memory in the caches reserved by the surrounding processors. If the processor is the static service, the static service is set to null.

Since:
2.8.1

disableOpen

public void disableOpen()
Description copied from interface: HasEnableDisableOpenMenus
Called when menus has to be set to "disabled" state

Specified by:
disableOpen in interface HasEnableDisableOpenMenus

enableOpen

public void enableOpen()
Description copied from interface: HasEnableDisableOpenMenus
Called when menus has to be set to "enables" state

Specified by:
enableOpen in interface HasEnableDisableOpenMenus

documentStoredEvent

public void documentStoredEvent(StorageEvent evt)
Specified by:
documentStoredEvent in interface StorageEventListener

isStored

public boolean isStored(java.net.URI uri,
                        org.hibernate.Session dbSession)
Returns true if the document with URI is already stored in the database

Parameters:
uri -
dbSession -
Returns:
boolean value true means yes, it is stored

getStorageThreads

public java.util.Collection<StoreXBRLThread> getStorageThreads()
Access to the collection of active threads. Some of them may already have finished working

Returns:

getStatus

public int getStatus(StoreXBRLThread th)

getStackTrace

public java.lang.String getStackTrace(StoreXBRLThread th)

getLastMessage

public java.lang.String getLastMessage(StoreXBRLThread th)

getTooltipMessage

public java.lang.String getTooltipMessage(StoreXBRLThread th)

getPercentage

public int getPercentage(StoreXBRLThread th)


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