org.gcube.application.aquamaps.aquamapsservice.impl.db
Class DBSession

java.lang.Object
  extended by org.gcube.application.aquamaps.aquamapsservice.impl.db.DBSession
Direct Known Subclasses:
MySQLDBSession, PostGresSQLDBSession

public abstract class DBSession
extends Object

Author:
lucio

Nested Class Summary
static class DBSession.ALTER_OPERATION
           
static class DBSession.ENGINE
           
 
Field Summary
protected  Connection connection
           
protected static String CSV_DELIMITER
           
protected static org.slf4j.Logger logger
           
 
Constructor Summary
protected DBSession()
          Deprecated. 
protected DBSession(Connection conn)
           
 
Method Summary
 void alterColumn(String tableName, DBSession.ALTER_OPERATION op, String... columnsAndConstraintDefinition)
           
abstract  boolean checkExist(String tableName, List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> keys)
           
 boolean checkTableExist(String tableName)
           
 void close()
           
 void commit()
           
 void createIndex(String tableName, String columnName)
           
abstract  void createLikeTable(String newTableName, String oldTable)
           
abstract  void createTable(String tableName, String[] columnsAndConstraintDefinition)
           
 void deleteColumn(String tableName, String columnName)
           
abstract  int deleteOperation(String tableName, List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters)
           
 void disableAutoCommit()
           
 void disableKeys(String tableName)
           
 void dropTable(String table)
           
 void dropView(String view)
           
 void enableKeys(String tableName)
           
abstract  ResultSet executeFilteredQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters, String table, String orderColumn, org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderMode)
           
 ResultSet executeQuery(String query)
          Deprecated. 
 void executeUpdate(String query)
          Deprecated. 
abstract  String exportTableToCSV(String tableName, boolean exportHeaders, char delimiter)
           
abstract  PreparedStatement fillParameters(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields, int parameterOffset, PreparedStatement ps)
           
protected static String formDeletetQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters, String table)
           
protected static String formSelectCountString(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters, String tableName)
           
protected static String formSelectDistinctQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters, org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field toSelectField, String table, String sortColumn, org.gcube_system.namespaces.application.aquamaps.types.OrderDirection sortDirection)
           
protected static String formSelectQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters, String table, String sortColumn, org.gcube_system.namespaces.application.aquamaps.types.OrderDirection sortDirection)
           
protected static String formUpdateQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> toSet, List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> keys, String tableName)
           
 Connection getConnection()
           
abstract  Long getCount(String tableName, List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters)
           
abstract  ResultSet getDistinct(org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field toSelect, List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters, String table, String orderColumn, org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderMode)
           
abstract  PreparedStatement getFilterCellByAreaQuery(org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.fields.HSPECFields filterByCodeType, String sourceTableName, String destinationTableName)
           
protected  List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> getGeneratedKeys(PreparedStatement ps)
           
static DBSession getInternalDBSession()
           
static DBSession getPostGisDBSession()
           
protected  PreparedStatement getPreparedStatementForCount(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters, String tableName)
           
 PreparedStatement getPreparedStatementForDelete(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields, String table)
           
 PreparedStatement getPreparedStatementForDISTINCT(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters, org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field toSelect, String table, String orderColumn, org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderDirection)
           
 PreparedStatement getPreparedStatementForInsert(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields, String table)
           
 PreparedStatement getPreparedStatementForInsertFromSelect(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields, String destTable, String srcTable)
           
abstract  PreparedStatement getPreparedStatementForInsertOnDuplicate(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields, String table, Integer[] keyIndexes)
           
 PreparedStatement getPreparedStatementForQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters, String table, String orderColumn, org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderDirection)
           
 PreparedStatement getPreparedStatementForUpdate(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> toSet, List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> keys, String tableName)
           
 long getTableCount(String tableName)
           
abstract  List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> insertOperation(String tableName, List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> rows)
           
 PreparedStatement preparedStatement(String query)
          Deprecated. 
abstract  int updateOperation(String tableName, List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> keys, List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> rows)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.slf4j.Logger logger

CSV_DELIMITER

protected static String CSV_DELIMITER

connection

protected Connection connection
Constructor Detail

DBSession

protected DBSession(Connection conn)

DBSession

@Deprecated
protected DBSession()
Deprecated. 

Method Detail

getConnection

public Connection getConnection()
Returns:
the connection

getInternalDBSession

public static DBSession getInternalDBSession()
                                      throws Exception
Returns:
Throws:
Exception

getPostGisDBSession

public static DBSession getPostGisDBSession()
                                     throws Exception
Throws:
Exception

close

public void close()
           throws Exception
Throws:
Exception

disableAutoCommit

public void disableAutoCommit()
                       throws Exception
Throws:
Exception

commit

public void commit()
            throws Exception
Throws:
Exception

executeQuery

@Deprecated
public ResultSet executeQuery(String query)
                       throws Exception
Deprecated. 

Parameters:
query -
Throws:
Exception

createTable

public abstract void createTable(String tableName,
                                 String[] columnsAndConstraintDefinition)
                          throws Exception
Throws:
Exception

disableKeys

public void disableKeys(String tableName)
                 throws Exception
Throws:
Exception

enableKeys

public void enableKeys(String tableName)
                throws Exception
Throws:
Exception

createLikeTable

public abstract void createLikeTable(String newTableName,
                                     String oldTable)
                              throws Exception
Throws:
Exception

alterColumn

public void alterColumn(String tableName,
                        DBSession.ALTER_OPERATION op,
                        String... columnsAndConstraintDefinition)
                 throws Exception
Throws:
Exception

createIndex

public void createIndex(String tableName,
                        String columnName)
                 throws Exception
Throws:
Exception

deleteColumn

public void deleteColumn(String tableName,
                         String columnName)
                  throws Exception
Throws:
Exception

dropTable

public void dropTable(String table)
               throws Exception
Throws:
Exception

dropView

public void dropView(String view)
              throws Exception
Throws:
Exception

getFilterCellByAreaQuery

public abstract PreparedStatement getFilterCellByAreaQuery(org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.fields.HSPECFields filterByCodeType,
                                                           String sourceTableName,
                                                           String destinationTableName)
                                                    throws Exception
Throws:
Exception

getPreparedStatementForCount

protected PreparedStatement getPreparedStatementForCount(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters,
                                                         String tableName)
                                                  throws SQLException
Throws:
SQLException

getPreparedStatementForQuery

public PreparedStatement getPreparedStatementForQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters,
                                                      String table,
                                                      String orderColumn,
                                                      org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderDirection)
                                               throws SQLException
Throws:
SQLException

getPreparedStatementForDISTINCT

public PreparedStatement getPreparedStatementForDISTINCT(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters,
                                                         org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field toSelect,
                                                         String table,
                                                         String orderColumn,
                                                         org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderDirection)
                                                  throws SQLException
Throws:
SQLException

getPreparedStatementForUpdate

public PreparedStatement getPreparedStatementForUpdate(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> toSet,
                                                       List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> keys,
                                                       String tableName)
                                                throws SQLException
Throws:
SQLException

getPreparedStatementForInsertFromSelect

public PreparedStatement getPreparedStatementForInsertFromSelect(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields,
                                                                 String destTable,
                                                                 String srcTable)
                                                          throws Exception
Throws:
Exception

getPreparedStatementForInsert

public PreparedStatement getPreparedStatementForInsert(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields,
                                                       String table)
                                                throws Exception
Throws:
Exception

getPreparedStatementForInsertOnDuplicate

public abstract PreparedStatement getPreparedStatementForInsertOnDuplicate(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields,
                                                                           String table,
                                                                           Integer[] keyIndexes)
                                                                    throws Exception
Throws:
Exception

getPreparedStatementForDelete

public PreparedStatement getPreparedStatementForDelete(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields,
                                                       String table)
                                                throws Exception
Throws:
Exception

preparedStatement

@Deprecated
public PreparedStatement preparedStatement(String query)
                                    throws Exception
Deprecated. 

Throws:
Exception

fillParameters

public abstract PreparedStatement fillParameters(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> fields,
                                                 int parameterOffset,
                                                 PreparedStatement ps)
                                          throws SQLException
Throws:
SQLException

exportTableToCSV

public abstract String exportTableToCSV(String tableName,
                                        boolean exportHeaders,
                                        char delimiter)
                                 throws Exception
Throws:
Exception

checkExist

public abstract boolean checkExist(String tableName,
                                   List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> keys)
                            throws Exception
Throws:
Exception

insertOperation

public abstract List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> insertOperation(String tableName,
                                                                                                                          List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> rows)
                                                                                                                   throws Exception
Throws:
Exception

updateOperation

public abstract int updateOperation(String tableName,
                                    List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> keys,
                                    List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> rows)
                             throws Exception
Throws:
Exception

executeFilteredQuery

public abstract ResultSet executeFilteredQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters,
                                               String table,
                                               String orderColumn,
                                               org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderMode)
                                        throws Exception
Throws:
Exception

getCount

public abstract Long getCount(String tableName,
                              List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters)
                       throws Exception
Throws:
Exception

deleteOperation

public abstract int deleteOperation(String tableName,
                                    List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters)
                             throws Exception
Throws:
Exception

getTableCount

public long getTableCount(String tableName)
                   throws Exception
Throws:
Exception

getDistinct

public abstract ResultSet getDistinct(org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field toSelect,
                                      List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters,
                                      String table,
                                      String orderColumn,
                                      org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderMode)
                               throws Exception
Throws:
Exception

executeUpdate

@Deprecated
public void executeUpdate(String query)
                   throws Exception
Deprecated. 

Throws:
Exception

checkTableExist

public boolean checkTableExist(String tableName)
                        throws Exception
Throws:
Exception

getGeneratedKeys

protected List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field>> getGeneratedKeys(PreparedStatement ps)
                                                                                                              throws SQLException
Throws:
SQLException

formSelectQueryStringFromFields

protected static String formSelectQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters,
                                                        String table,
                                                        String sortColumn,
                                                        org.gcube_system.namespaces.application.aquamaps.types.OrderDirection sortDirection)

formSelectDistinctQueryStringFromFields

protected static String formSelectDistinctQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters,
                                                                org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field toSelectField,
                                                                String table,
                                                                String sortColumn,
                                                                org.gcube_system.namespaces.application.aquamaps.types.OrderDirection sortDirection)

formSelectCountString

protected static String formSelectCountString(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters,
                                              String tableName)

formDeletetQueryStringFromFields

protected static String formDeletetQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> filters,
                                                         String table)

formUpdateQuery

protected static String formUpdateQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> toSet,
                                        List<org.gcube.application.aquamaps.aquamapsservice.stubs.datamodel.enhanced.Field> keys,
                                        String tableName)


Copyright © 2013. All Rights Reserved.