Class DBUtil
- java.lang.Object
-
- in.cdac.medinfo.csnotk.csnolib.db.DBUtil
-
public class DBUtil extends java.lang.ObjectDatabase 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 voidcloseConnection(java.sql.Connection connection)Closes given instance ofConnection.static voidcloseResultSet(java.sql.ResultSet resultSet)Closes given instance ofResultSet.static voidcloseStatement(java.sql.Statement statement)Closes given instance ofStatement.static java.lang.StringgetConceptFSN(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.StatementgetStatement(java.sql.Connection connection)Gets instance ofStatementfor database operation.static longgetTotalExtensionCount(java.lang.String moduleId, java.sql.Statement statement)Returns count of total number of rows of an Extension in Concept Table.static longgetTotalRefsetCount(java.lang.String refsetId, java.sql.Statement statement)Returns count of total number of rows of Refset and cRefset Table.static longgetTotalRefsetRows(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 longgetTotalRows(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.ResultSetretrieveAcceptabilityId(java.lang.String descriptionId, java.sql.Statement statement)Retrieves Acceptability id of description which indicates preferred term for that description.static java.sql.ResultSetretrieveAll(java.lang.String tableName, java.sql.Statement statement)Fetches all rows from specified database table associated with given instance ofStatement.static java.sql.ResultSetretrieveColumns(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.ResultSetretrieveConceptDetails(java.lang.String conceptId, java.lang.String languageCode, java.sql.Statement statement)RetrievesConcept details.static java.sql.ResultSetretrieveConceptDetails(java.lang.String conceptId, java.sql.Statement statement)RetrievesConcept details.static java.sql.ResultSetretrieveConceptState(java.lang.String conceptId, java.sql.Statement statement)Retrieves Concept state of Specified Concept ID.static java.sql.ResultSetretrievecRefsetColumns(java.lang.String refsetId, java.sql.Statement statement, long offset, long returnLimit, java.util.Set<java.lang.String> moduleIdSet, boolean flag)Fetches Description data for the specified Refset Id using offset and returnLimit values.static java.sql.ResultSetretrieveFSNforHierachy(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.ResultSetretrieveRefsetColumns(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.
-
-
-
Method Detail
-
getStatement
public static java.sql.Statement getStatement(java.sql.Connection connection) throws java.sql.SQLExceptionGets instance ofStatementfor 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.SQLExceptionFetches all rows from specified database table associated with given instance ofStatement.- Parameters:
tableName- table in which the query has to be fired.statement-Statementinstance.- 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.SQLExceptionFetches specified columns data using offset and returnLimit values.- Parameters:
tableName- table in which the query has to be fired.columnArray- List of columns.statement-Statementinstance.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.SQLExceptionRetrieves Term and Type ID of description id which is FSN.- Parameters:
conceptId- concept identifier.statement-Statementclass instance.- Returns:
ResultSetobtained 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.SQLExceptionRetrievesConcept details.- Parameters:
conceptId- concept id.languageCode- Description Language Codestatement-Statementclass instance.- Throws:
java.sql.SQLException
-
retrieveConceptDetails
public static java.sql.ResultSet retrieveConceptDetails(java.lang.String conceptId, java.sql.Statement statement) throws java.sql.SQLExceptionRetrievesConcept details.- Parameters:
conceptId- concept id.statement-Statementclass instance.- Throws:
java.sql.SQLException
-
retrieveAcceptabilityId
public static java.sql.ResultSet retrieveAcceptabilityId(java.lang.String descriptionId, java.sql.Statement statement) throws java.sql.SQLExceptionRetrieves 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.SQLExceptionRetrieves Concept state of Specified Concept ID.- Parameters:
conceptId- concept id.statement-Statementclass instance.- Returns:
ResultSetthat 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.SQLExceptionCloses given instance ofConnection.- Parameters:
connection-Connectionclass object.- Throws:
java.sql.SQLException
-
closeStatement
public static void closeStatement(java.sql.Statement statement) throws java.sql.SQLExceptionCloses given instance ofStatement.- Parameters:
statement-Statementobject.- Throws:
java.sql.SQLException
-
closeResultSet
public static void closeResultSet(java.sql.ResultSet resultSet) throws java.sql.SQLExceptionCloses given instance ofResultSet.- Parameters:
resultSet- instance ofResultSet.- Throws:
java.sql.SQLException
-
getTotalRows
public static long getTotalRows(java.lang.String tableName, java.sql.Statement statement, java.lang.String moduleId) throws java.sql.SQLExceptionGets count of total number of rows in specified table.- Parameters:
tableName- Name of the table to be retrieved.statement-Statementinstance.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.SQLExceptionFetches 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-Statementinstance.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.SQLExceptionFetches 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-Statementinstance.offset- the offset.returnLimit- the maximum number of results to be obtained.moduleIdSet-- Returns:
- result set obtained on the execution of the query.
- 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.SQLExceptionReturns count of total number of rows of Description Table which are required for a particular Refset .- Parameters:
moduleId- module Identifier .statement-Statementinstance.- 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.SQLExceptionReturns count of total number of rows of Description Table which are required for a particular Refset .- Parameters:
moduleId- module Identifier .statement-Statementinstance.- 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.SQLExceptionReturns count of total number of rows of Description Table which are required for a particular Refset .- Parameters:
refsetId- Refset Identifier .statement-Statementinstance.- 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.SQLExceptionReturns count of total number of rows of Refset and cRefset Table.- Parameters:
refsetId- Refset Identifier .statement-Statementinstance.- 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.SQLExceptionReturns 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.SQLExceptionReturns 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
-
-