org.gcube.dataanalysis.ecoengine.utils
Class DatabaseUtils

java.lang.Object
  extended by org.gcube.dataanalysis.ecoengine.utils.DatabaseUtils

public class DatabaseUtils
extends Object


Field Summary
 List<Object> columns
           
 
Constructor Summary
DatabaseUtils(org.hibernate.SessionFactory referencedbConnection)
           
 
Method Summary
static String addColumnStatement(String tableToUpdate, String columnName, String columnKey)
           
 String buildCreateStatement(String originaltable, String destinationTable)
           
static void closeDBConnection(org.hibernate.SessionFactory dbHibConnection)
           
static String copyFileToTableStatement(String file, String table)
           
static String countElementsStatement(String table)
           
static void createBigTable(boolean createTable, String table, String dbdriver, String dbuser, String dbpassword, String dburl, String creationStatement, org.hibernate.SessionFactory dbHibConnection)
           
static String createBlankTableFromAnotherStatement(String tableFrom, String tableTo)
           
static void createRemoteTableFromFile(String filePath, String tablename, String delimiter, boolean hasHeader, String username, String password, String databaseurl)
           
static String createUpdateStatement(String tableToUpdate, String fieldToUpdate, String tableFromUpdate, String columnFromUpdate, String tableToUpKey, String tableFromUpKey)
           
static String deleteFromBuffer(String table, StringBuffer couples)
           
static String dropTableStatement(String table)
           
static String duplicateTableStatement(String tableFrom, String tableTo)
           
 List<Object> getColumnDecriptions()
           
 String getColumnName(int index)
           
static String getColumnsElementsStatement(String table, String columns, String filter)
           
static String getColumnsNamesStatement(String table)
           
 String getColumnType(int index)
           
static String getDinstictElements(String table, String columns, String filter)
           
static String getOrderedElements(String table, String key, String column)
           
 String getPrimaryKey()
           
static org.hibernate.SessionFactory initDBSession(AlgorithmConfiguration config)
           
static String insertFromBuffer(String table, String columnsNames, StringBuffer values)
           
static String insertFromString(String table, String columnsNames, String values)
           
static String insertIntoColumn(String table, String keyColumnName, String valueColumnName, List<Object> couplesColumnAndKeys)
           
static String sumElementsStatement(String table, String column)
           
static String update(String table, String valueColumnName, String value, String keyColumnName, String key)
           
static String updateColumn(String table, String keyColumnName, String valueColumnName, List<Object> couplesColumnAndKeys)
           
static String updateTableColumnFromOther(String tableName, String fieldToUpdate, String otherTable, String otherColumn, String keyColumn, String otherKeyColumn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columns

public List<Object> columns
Constructor Detail

DatabaseUtils

public DatabaseUtils(org.hibernate.SessionFactory referencedbConnection)
Method Detail

createUpdateStatement

public static String createUpdateStatement(String tableToUpdate,
                                           String fieldToUpdate,
                                           String tableFromUpdate,
                                           String columnFromUpdate,
                                           String tableToUpKey,
                                           String tableFromUpKey)

addColumnStatement

public static String addColumnStatement(String tableToUpdate,
                                        String columnName,
                                        String columnKey)

getPrimaryKey

public String getPrimaryKey()

getColumnDecriptions

public List<Object> getColumnDecriptions()

getColumnName

public String getColumnName(int index)

getColumnType

public String getColumnType(int index)

duplicateTableStatement

public static String duplicateTableStatement(String tableFrom,
                                             String tableTo)

createBlankTableFromAnotherStatement

public static String createBlankTableFromAnotherStatement(String tableFrom,
                                                          String tableTo)

dropTableStatement

public static String dropTableStatement(String table)

getDinstictElements

public static String getDinstictElements(String table,
                                         String columns,
                                         String filter)

getOrderedElements

public static String getOrderedElements(String table,
                                        String key,
                                        String column)

sumElementsStatement

public static String sumElementsStatement(String table,
                                          String column)

getColumnsElementsStatement

public static String getColumnsElementsStatement(String table,
                                                 String columns,
                                                 String filter)

countElementsStatement

public static String countElementsStatement(String table)

update

public static String update(String table,
                            String valueColumnName,
                            String value,
                            String keyColumnName,
                            String key)

insertIntoColumn

public static String insertIntoColumn(String table,
                                      String keyColumnName,
                                      String valueColumnName,
                                      List<Object> couplesColumnAndKeys)

insertFromBuffer

public static String insertFromBuffer(String table,
                                      String columnsNames,
                                      StringBuffer values)

insertFromString

public static String insertFromString(String table,
                                      String columnsNames,
                                      String values)

deleteFromBuffer

public static String deleteFromBuffer(String table,
                                      StringBuffer couples)

copyFileToTableStatement

public static String copyFileToTableStatement(String file,
                                              String table)

updateTableColumnFromOther

public static String updateTableColumnFromOther(String tableName,
                                                String fieldToUpdate,
                                                String otherTable,
                                                String otherColumn,
                                                String keyColumn,
                                                String otherKeyColumn)

updateColumn

public static String updateColumn(String table,
                                  String keyColumnName,
                                  String valueColumnName,
                                  List<Object> couplesColumnAndKeys)

buildCreateStatement

public String buildCreateStatement(String originaltable,
                                   String destinationTable)

getColumnsNamesStatement

public static String getColumnsNamesStatement(String table)

createBigTable

public static void createBigTable(boolean createTable,
                                  String table,
                                  String dbdriver,
                                  String dbuser,
                                  String dbpassword,
                                  String dburl,
                                  String creationStatement,
                                  org.hibernate.SessionFactory dbHibConnection)
                           throws Exception
Throws:
Exception

createRemoteTableFromFile

public static void createRemoteTableFromFile(String filePath,
                                             String tablename,
                                             String delimiter,
                                             boolean hasHeader,
                                             String username,
                                             String password,
                                             String databaseurl)
                                      throws Exception
Throws:
Exception

initDBSession

public static org.hibernate.SessionFactory initDBSession(AlgorithmConfiguration config)

closeDBConnection

public static void closeDBConnection(org.hibernate.SessionFactory dbHibConnection)


Copyright © 2013. All Rights Reserved.