Package in.cdac.medinfo.csnotk.csnolib.db

## Class DBUtil

- java.lang.Object
- - in.cdac.medinfo.csnotk.csnolib.db.DBUtil

-     public class DBUtil
      extends java.lang.Object

  Database resource provider utility for query generation and data fetching.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DBUtil()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `closeConnection​(java.sql.Connection connection)` | Closes given instance of `Connection`.
    `static void` | `closeResultSet​(java.sql.ResultSet resultSet)` | Closes given instance of `ResultSet`.
    `static void` | `closeStatement​(java.sql.Statement statement)` | Closes given instance of `Statement`.
    `static java.lang.String` | `getConceptFSN​(java.lang.String moduleId, java.sql.Statement statement)` | Returns Fully Specified Name (FSN) of a given concept ID.
    `static java.util.HashMap<java.lang.String,​java.lang.String>` | `getDistinctcRefsetId​(java.lang.String moduleId, java.sql.Statement statement)` | Returns count of total number of rows of Description Table which are required for a particular Refset .
    `static java.util.HashMap<java.lang.String,​java.lang.String>` | `getDistinctRefsetId​(java.lang.String moduleId, java.lang.String refsetId, java.sql.Statement statement)` | Returns count of total number of rows of Description Table which are required for a particular Refset .
    `static java.sql.Statement` | `getStatement​(java.sql.Connection connection)` | Gets instance of `Statement` for database operation.
    `static long` | `getTotalExtensionCount​(java.lang.String moduleId, java.sql.Statement statement)` | Returns count of total number of rows of an Extension in Concept Table.
    `static long` | `getTotalRefsetCount​(java.lang.String refsetId, java.sql.Statement statement)` | Returns count of total number of rows of Refset and cRefset Table.
    `static long` | `getTotalRefsetRows​(java.lang.String refsetId, java.sql.Statement statement)` | Returns count of total number of rows of Description Table which are required for a particular Refset .
    `static long` | `getTotalRows​(java.lang.String tableName, java.sql.Statement statement, java.lang.String moduleId)` | Gets count of total number of rows in specified table.
    `static java.sql.ResultSet` | `retrieveAcceptabilityId​(java.lang.String descriptionId, java.sql.Statement statement)` | Retrieves Acceptability id of description which indicates preferred term for that description.
    `static java.sql.ResultSet` | `retrieveAll​(java.lang.String tableName, java.sql.Statement statement)` | Fetches all rows from specified database table associated with given instance of `Statement`.
    `static java.sql.ResultSet` | `retrieveColumns​(java.lang.String tableName, java.lang.String[] columnArray, java.sql.Statement statement, long offset, long returnLimit, boolean isExtensionSelected)` | Fetches specified columns data using offset and returnLimit values.
    `static java.sql.ResultSet` | `retrieveConceptDetails​(java.lang.String conceptId, java.lang.String languageCode, java.sql.Statement statement)` | RetrievesConcept details.
    `static java.sql.ResultSet` | `retrieveConceptDetails​(java.lang.String conceptId, java.sql.Statement statement)` | RetrievesConcept details.
    `static java.sql.ResultSet` | `retrieveConceptState​(java.lang.String conceptId, java.sql.Statement statement)` | Retrieves Concept state of Specified Concept ID.
    `static java.sql.ResultSet` | `retrievecRefsetColumns​(java.lang.String refsetId, java.sql.Statement statement, long offset, long returnLimit, java.util.Set<java.lang.String> moduleIdSet, boolean flag)` |
    `static java.sql.ResultSet` | `retrieveFSNforHierachy​(java.lang.String conceptId, java.sql.Statement statement, java.lang.String languageCode)` | Retrieves Term and Type ID of description id which is FSN.
    `static java.sql.ResultSet` | `retrieveRefsetColumns​(java.lang.String refsetId, java.sql.Statement statement, long offset, long returnLimit)` | Fetches Description data for the specified Refset Id using offset and returnLimit values.

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

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

- - ### Constructor Detail

    - #### DBUtil

          public DBUtil()

  - ### Method Detail

    - #### getStatement

          public static java.sql.Statement getStatement​(java.sql.Connection connection)
                                                 throws java.sql.SQLException

      Gets instance of `Statement` for database operation.
      Parameters:
        `connection` - Connection object.
      Returns:
        instance of `Statement`.
      Throws:
        `java.sql.SQLException`

    - #### retrieveAll

          public static java.sql.ResultSet retrieveAll​(java.lang.String tableName,
                                                       java.sql.Statement statement)
                                                throws java.sql.SQLException

      Fetches all rows from specified database table associated with given instance of `Statement`.
      Parameters:
        `tableName` - table in which the query has to be fired.
        `statement` - `Statement` instance.
      Returns:
        result set obtained on firing the query on DB.
      Throws:
        `java.sql.SQLException`

    - #### retrieveColumns

          public static java.sql.ResultSet retrieveColumns​(java.lang.String tableName,
                                                           java.lang.String[] columnArray,
                                                           java.sql.Statement statement,
                                                           long offset,
                                                           long returnLimit,
                                                           boolean isExtensionSelected)
                                                    throws java.sql.SQLException

      Fetches specified columns data using offset and returnLimit values.
      Parameters:
        `tableName` - table in which the query has to be fired.
        `columnArray` - List of columns.
        `statement` - `Statement` instance.
        `offset` - the offset.
        `returnLimit` - the maximum number of results to be obtained.
      Returns:
        result set obtained on the execution of the query.
      Throws:
        `java.sql.SQLException`

    - #### retrieveFSNforHierachy

          public static java.sql.ResultSet retrieveFSNforHierachy​(java.lang.String conceptId,
                                                                  java.sql.Statement statement,
                                                                  java.lang.String languageCode)
                                                           throws java.sql.SQLException

      Retrieves Term and Type ID of description id which is FSN.
      Parameters:
        `conceptId` - concept identifier.
        `statement` - `Statement` class instance.
      Returns:
        `ResultSet` obtained on DB query execution.
      Throws:
        `java.sql.SQLException`

    - #### retrieveConceptDetails

          public static java.sql.ResultSet retrieveConceptDetails​(java.lang.String conceptId,
                                                                  java.lang.String languageCode,
                                                                  java.sql.Statement statement)
                                                           throws java.sql.SQLException

      RetrievesConcept details.
      Parameters:
        `conceptId` - concept id.
        `languageCode` - Description Language Code
        `statement` - `Statement` class instance.
      Throws:
        `java.sql.SQLException`

    - #### retrieveConceptDetails

          public static java.sql.ResultSet retrieveConceptDetails​(java.lang.String conceptId,
                                                                  java.sql.Statement statement)
                                                           throws java.sql.SQLException

      RetrievesConcept details.
      Parameters:
        `conceptId` - concept id.
        `statement` - `Statement` class instance.
      Throws:
        `java.sql.SQLException`

    - #### retrieveAcceptabilityId

          public static java.sql.ResultSet retrieveAcceptabilityId​(java.lang.String descriptionId,
                                                                   java.sql.Statement statement)
                                                            throws java.sql.SQLException

      Retrieves Acceptability id of description which indicates preferred term for that description.
      Parameters:
        `descriptionId` - description id.
      Returns:
        acceptability id the refset acceptability id corresponding to that description.
      Throws:
        `java.sql.SQLException`

    - #### retrieveConceptState

          public static java.sql.ResultSet retrieveConceptState​(java.lang.String conceptId,
                                                                java.sql.Statement statement)
                                                         throws java.sql.SQLException

      Retrieves Concept state of Specified Concept ID.
      Parameters:
        `conceptId` - concept id.
        `statement` - `Statement` class instance.
      Returns:
        `ResultSet` that is actually the Concept state for that particular concept id.
      Throws:
        `java.sql.SQLException`

    - #### closeConnection

          public static void closeConnection​(java.sql.Connection connection)
                                      throws java.sql.SQLException

      Closes given instance of `Connection`.
      Parameters:
        `connection` - `Connection` class object.
      Throws:
        `java.sql.SQLException`

    - #### closeStatement

          public static void closeStatement​(java.sql.Statement statement)
                                     throws java.sql.SQLException

      Closes given instance of `Statement`.
      Parameters:
        `statement` - `Statement` object.
      Throws:
        `java.sql.SQLException`

    - #### closeResultSet

          public static void closeResultSet​(java.sql.ResultSet resultSet)
                                     throws java.sql.SQLException

      Closes given instance of `ResultSet`.
      Parameters:
        `resultSet` - instance of `ResultSet`.
      Throws:
        `java.sql.SQLException`

    - #### getTotalRows

          public static long getTotalRows​(java.lang.String tableName,
                                          java.sql.Statement statement,
                                          java.lang.String moduleId)
                                   throws java.sql.SQLException

      Gets count of total number of rows in specified table.
      Parameters:
        `tableName` - Name of the table to be retrieved.
        `statement` - `Statement` instance.
        `moduleId` - ModuleId concept for extension and refset, pass this if require constrain search. Default value is null
      Returns:
        totalRows the total number of rows obtained on executing the query.
      Throws:
        `java.sql.SQLException`

    - #### retrieveRefsetColumns

          public static java.sql.ResultSet retrieveRefsetColumns​(java.lang.String refsetId,
                                                                 java.sql.Statement statement,
                                                                 long offset,
                                                                 long returnLimit)
                                                          throws java.sql.SQLException

      Fetches Description data for the specified Refset Id using offset and returnLimit values.
      Parameters:
        `refsetId` - identifier of Refset for which data is to be retrieved.
        `statement` - `Statement` instance.
        `offset` - the offset.
        `returnLimit` - the maximum number of results to be obtained.
      Returns:
        result set obtained on the execution of the query.
      Throws:
        `java.sql.SQLException`

    - #### retrievecRefsetColumns

          public static java.sql.ResultSet retrievecRefsetColumns​(java.lang.String refsetId,
                                                                  java.sql.Statement statement,
                                                                  long offset,
                                                                  long returnLimit,
                                                                  java.util.Set<java.lang.String> moduleIdSet,
                                                                  boolean flag)
                                                           throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### getDistinctRefsetId

          public static java.util.HashMap<java.lang.String,​java.lang.String> getDistinctRefsetId​(java.lang.String moduleId,
                                                                                                       java.lang.String refsetId,
                                                                                                       java.sql.Statement statement)
                                                                                                throws java.sql.SQLException

      Returns count of total number of rows of Description Table which are required for a particular Refset .
      Parameters:
        `moduleId` - module Identifier .
        `statement` - `Statement` instance.
      Returns:
        refsetId_list distinct refsetId obtained on executing the query.
      Throws:
        `java.sql.SQLException`

    - #### getDistinctcRefsetId

          public static java.util.HashMap<java.lang.String,​java.lang.String> getDistinctcRefsetId​(java.lang.String moduleId,
                                                                                                        java.sql.Statement statement)
                                                                                                 throws java.sql.SQLException

      Returns count of total number of rows of Description Table which are required for a particular Refset .
      Parameters:
        `moduleId` - module Identifier .
        `statement` - `Statement` instance.
      Returns:
        refsetId_list distinct refsetId obtained on executing the query.
      Throws:
        `java.sql.SQLException`

    - #### getTotalRefsetRows

          public static long getTotalRefsetRows​(java.lang.String refsetId,
                                                java.sql.Statement statement)
                                         throws java.sql.SQLException

      Returns count of total number of rows of Description Table which are required for a particular Refset .
      Parameters:
        `refsetId` - Refset Identifier .
        `statement` - `Statement` instance.
      Returns:
        totalRows the total number of rows obtained on executing the query.
      Throws:
        `java.sql.SQLException`

    - #### getTotalRefsetCount

          public static long getTotalRefsetCount​(java.lang.String refsetId,
                                                 java.sql.Statement statement)
                                          throws java.sql.SQLException

      Returns count of total number of rows of Refset and cRefset Table.
      Parameters:
        `refsetId` - Refset Identifier .
        `statement` - `Statement` instance.
      Returns:
        totalRows the total number of rows obtained on executing the query.
      Throws:
        `java.sql.SQLException`

    - #### getTotalExtensionCount

          public static long getTotalExtensionCount​(java.lang.String moduleId,
                                                    java.sql.Statement statement)
                                             throws java.sql.SQLException

      Returns count of total number of rows of an Extension in Concept Table.
      Parameters:
        `moduleId` - Module Identifier .
      Returns:
        totalRows the total number of rows obtained on executing the query.
      Throws:
        `java.sql.SQLException`

    - #### getConceptFSN

          public static java.lang.String getConceptFSN​(java.lang.String moduleId,
                                                       java.sql.Statement statement)
                                                throws java.sql.SQLException

      Returns Fully Specified Name (FSN) of a given concept ID.
      Parameters:
        `moduleId` - Module Identifier .
      Returns:
        conceptFSN Fully Specified Name of given concept ID
      Throws:
        `java.sql.SQLException`