org.gcube.application.aquamaps.aquamapsservice.impl.db
Class DBSession
java.lang.Object
org.gcube.application.aquamaps.aquamapsservice.impl.db.DBSession
- Direct Known Subclasses:
- MySQLDBSession, PostGresSQLDBSession
public abstract class DBSession
- extends Object
- Author:
- lucio
|
Method Summary |
void |
alterColumn(String tableName,
DBSession.ALTER_OPERATION op,
String... columnsAndConstraintDefinition)
|
abstract boolean |
checkExist(String tableName,
List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.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.fw.model.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.fw.model.Field> fields,
int parameterOffset,
PreparedStatement ps)
|
protected static String |
formDeletetQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters,
String table)
|
protected static String |
formSelectCountString(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters,
String tableName)
|
protected static String |
formSelectDistinctQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters,
org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.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.fw.model.Field> toSet,
List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> keys,
String tableName)
|
Connection |
getConnection()
|
abstract Long |
getCount(String tableName,
List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters)
|
abstract ResultSet |
getDistinct(org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field toSelect,
List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters,
String table,
String orderColumn,
org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderMode)
|
abstract PreparedStatement |
getFilterCellByAreaQuery(org.gcube.application.aquamaps.aquamapsservice.stubs.fw.fields.HSPECFields filterByCodeType,
String sourceTableName,
String destinationTableName)
|
protected List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field>> |
getGeneratedKeys(PreparedStatement ps)
|
static DBSession |
getInternalDBSession()
|
static DBSession |
getPostGisDBSession()
|
protected PreparedStatement |
getPreparedStatementForCount(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters,
String tableName)
|
PreparedStatement |
getPreparedStatementForDelete(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> fields,
String table)
|
PreparedStatement |
getPreparedStatementForDISTINCT(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters,
org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field toSelect,
String table,
String orderColumn,
org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderDirection)
|
PreparedStatement |
getPreparedStatementForInsert(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> fields,
String table)
|
PreparedStatement |
getPreparedStatementForInsertFromSelect(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> fields,
String destTable,
String srcTable)
|
abstract PreparedStatement |
getPreparedStatementForInsertOnDuplicate(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> fields,
String table,
Integer[] keyIndexes)
|
PreparedStatement |
getPreparedStatementForQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters,
String table,
String orderColumn,
org.gcube_system.namespaces.application.aquamaps.types.OrderDirection orderDirection)
|
PreparedStatement |
getPreparedStatementForUpdate(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> toSet,
List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> keys,
String tableName)
|
long |
getTableCount(String tableName)
|
abstract List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field>> |
insertOperation(String tableName,
List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field>> rows)
|
PreparedStatement |
preparedStatement(String query)
Deprecated. |
abstract int |
updateOperation(String tableName,
List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field>> keys,
List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field>> rows)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected static final org.slf4j.Logger logger
CSV_DELIMITER
protected static String CSV_DELIMITER
connection
protected Connection connection
DBSession
protected DBSession(Connection conn)
DBSession
@Deprecated
protected DBSession()
- Deprecated.
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.fw.fields.HSPECFields filterByCodeType,
String sourceTableName,
String destinationTableName)
throws Exception
- Throws:
Exception
getPreparedStatementForCount
protected PreparedStatement getPreparedStatementForCount(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters,
String tableName)
throws SQLException
- Throws:
SQLException
getPreparedStatementForQuery
public PreparedStatement getPreparedStatementForQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.Field> filters,
org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.Field> toSet,
List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> keys,
String tableName)
throws SQLException
- Throws:
SQLException
getPreparedStatementForInsertFromSelect
public PreparedStatement getPreparedStatementForInsertFromSelect(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> fields,
String destTable,
String srcTable)
throws Exception
- Throws:
Exception
getPreparedStatementForInsert
public PreparedStatement getPreparedStatementForInsert(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> fields,
String table)
throws Exception
- Throws:
Exception
getPreparedStatementForInsertOnDuplicate
public abstract PreparedStatement getPreparedStatementForInsertOnDuplicate(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> fields,
String table,
Integer[] keyIndexes)
throws Exception
- Throws:
Exception
getPreparedStatementForDelete
public PreparedStatement getPreparedStatementForDelete(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.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.fw.model.Field> keys)
throws Exception
- Throws:
Exception
insertOperation
public abstract List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field>> insertOperation(String tableName,
List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field>> rows)
throws Exception
- Throws:
Exception
updateOperation
public abstract int updateOperation(String tableName,
List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field>> keys,
List<List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field>> rows)
throws Exception
- Throws:
Exception
executeFilteredQuery
public abstract ResultSet executeFilteredQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.Field> filters)
throws Exception
- Throws:
Exception
deleteOperation
public abstract int deleteOperation(String tableName,
List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.Field toSelect,
List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.Field>> getGeneratedKeys(PreparedStatement ps)
throws SQLException
- Throws:
SQLException
formSelectQueryStringFromFields
protected static String formSelectQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.Field> filters,
org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.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.fw.model.Field> filters,
String tableName)
formDeletetQueryStringFromFields
protected static String formDeletetQueryStringFromFields(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> filters,
String table)
formUpdateQuery
protected static String formUpdateQuery(List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> toSet,
List<org.gcube.application.aquamaps.aquamapsservice.stubs.fw.model.Field> keys,
String tableName)
Copyright © 2014. All Rights Reserved.