com.ihr.xbrl.pojo

## Class XBRLDBAccessor

- java.lang.Object
- - com.ihr.xbrl.pojo.XBRLDBAccessor

-     public class XBRLDBAccessor
      extends java.lang.Object

  Methods to query the database for the existence of documents os other objects.
  Author:
    Ignacio

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `org.apache.log4j.Logger` | `log` The log.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBRLDBAccessor(org.hibernate.Session session, DbUtil.Database databaseType)` Creates an instance of the XBRLDBAcessor object to query the database for the existence of objects.
    `XBRLDBAccessor(org.hibernate.Session session, DbUtil.Database databaseType, XBRLPojoGenerator xbrlPojoGenerator)` Creates an instance of the XBRLDBAcessor object to query the database for the existence of objects.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DbUtil.Database` | `getDatabaseType()` Gets the database type.
    `XBRLArcroleType` | `queryArcrole(java.lang.String uri)` Query arcrole.
    `XBRLItem` | `queryConceptItem(java.lang.Long id)` Query concept item.
    `XBRLTuple` | `queryConceptTuple(java.lang.Long id)` Query concept tuple.
    `XBRLDocument` | `queryDocument(java.net.URI documentURI)` Query document.
    `XBRLInstance` | `queryDocument(XBRLInstance instance)` Query the database for the existence of an XBRLInstance document.
    `XBRLLinkbase` | `queryDocument(XBRLLinkbase linkbase)` Query the database for the existence of an XBRLLinkbase document.
    `XBRLTaxonomy` | `queryDocument(XBRLTaxonomy taxonomy)` Query the database for the existence of an XBRLTaxonomy document.
    `XBRLFactProperty` | `queryFactProperty(XBRLFactItem fact, int container, XMLFragment property)` Search on the database for a property in the XBRLFactProperty table that matches the selection criteria according with the primary key that is created using the fact ID, the container and the property node ID.
    `Namespace` | `queryNamespace(javax.xml.namespace.QName q)` Query namespace.
    `QName` | `queryQName(javax.xml.namespace.QName q)` Query q name.
    `XBRLRoleType` | `queryRole(java.lang.String uri)` Query role.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### log

          public org.apache.log4j.Logger log

      The log.

  - ### Constructor Detail

    - #### XBRLDBAccessor

          public XBRLDBAccessor(org.hibernate.Session session,
                        DbUtil.Database databaseType)

      Creates an instance of the XBRLDBAcessor object to query the database for the existence of objects.

      This constructor can be used only for querying documents. Not QNames and not for storing new data.

      Parameters:
        `session` - the session
        `databaseType` - the database type

    - #### XBRLDBAccessor

          public XBRLDBAccessor(org.hibernate.Session session,
                        DbUtil.Database databaseType,
                        XBRLPojoGenerator xbrlPojoGenerator)

      Creates an instance of the XBRLDBAcessor object to query the database for the existence of objects.
      Parameters:
        `session` - the session
        `databaseType` - the database type
        `xbrlPojoGenerator` - the xbrl pojo generator

  - ### Method Detail

    - #### queryDocument

          public XBRLInstance queryDocument(XBRLInstance instance)

      Query the database for the existence of an XBRLInstance document.
      Parameters:
        `instance` - XBRLInstance document in the RS object model.
      Returns:
        instance in the POJO object model from the database if found or null if not found

    - #### queryDocument

          public XBRLLinkbase queryDocument(XBRLLinkbase linkbase)

      Query the database for the existence of an XBRLLinkbase document.
      Parameters:
        `linkbase` - XBRLLinkbase document in the RS object model.
      Returns:
        linkbase in the POJO object model from the database if found or null if not found

    - #### queryDocument

          public XBRLTaxonomy queryDocument(XBRLTaxonomy taxonomy)

      Query the database for the existence of an XBRLTaxonomy document.
      Parameters:
        `taxonomy` - XBRLTaxonomy document in the RS object model.
      Returns:
        taxonomy in the POJO object model from the database if found or null if not found

    - #### queryDocument

          public XBRLDocument queryDocument(java.net.URI documentURI)

      Query document.
      Parameters:
        `documentURI` - the URI of a document
      Returns:
        the XBRLDocument from the database

    - #### queryConceptItem

          public XBRLItem queryConceptItem(java.lang.Long id)

      Query concept item.
      Parameters:
        `id` - the id
      Returns:
        the XBRL item

    - #### queryConceptTuple

          public XBRLTuple queryConceptTuple(java.lang.Long id)

      Query concept tuple.
      Parameters:
        `id` - the id
      Returns:
        the XBRL tuple

    - #### queryQName

          public QName queryQName(javax.xml.namespace.QName q)
                           throws XBRLPojoGenerationException

      Query q name.
      Parameters:
        `q` - the q
      Returns:
        the com.ihr.xbrl.pojo. q name
      Throws:
        `XBRLPojoGenerationException`

    - #### queryNamespace

          public Namespace queryNamespace(javax.xml.namespace.QName q)

      Query namespace.
      Parameters:
        `q` - the q
      Returns:
        the namespace

    - #### queryRole

          public XBRLRoleType queryRole(java.lang.String uri)

      Query role.
      Parameters:
        `uri` - the uri
      Returns:
        the com.ihr.xbrl.pojo. xbrl role type

    - #### queryArcrole

          public XBRLArcroleType queryArcrole(java.lang.String uri)

      Query arcrole.
      Parameters:
        `uri` - the uri
      Returns:
        the com.ihr.xbrl.pojo. xbrl arcrole type

    - #### getDatabaseType

          public DbUtil.Database getDatabaseType()

      Gets the database type.
      Returns:
        the databaseType

    - #### queryFactProperty

          public XBRLFactProperty queryFactProperty(XBRLFactItem fact,
                                           int container,
                                           XMLFragment property)

      Search on the database for a property in the XBRLFactProperty table that matches the selection criteria according with the primary key that is created using the fact ID, the container and the property node ID.

      One may think the container should not be part of the key, as the property is an XMLFragment that belongs to a specific container (segment or scenario), we have included the container as a specific property in order to allow virtual properties to be explicitly declared in the database. Virtual properties may be an XMLFragment node in its own and be at no container at all (default values for explicit dimensions are an example of this).

      Parameters:
        `fact` - the fact
        `container` - the container
        `property` - the property
      Returns:
        the XBRL fact property