public class DatabaseFacade extends Observable
Constructor and Description |
---|
DatabaseFacade()
constructor
|
Modifier and Type | Method and Description |
---|---|
String[][] |
cellsTo2dArray(Cell[][] cells)
converts selected spreadsheet content in a 2D String array
|
boolean |
compareCellsWithDB(String[][] tableData,
String[][] selectedCells)
compares if there's any difference in content between the selected cells
in the spreadsheet and the ones imported from the DB
|
void |
createConnection(String url,
String user,
String pass,
String dbName)
creates a connection to a database driver
|
void |
exportData(Cell[][] cells,
String tableName)
exports data to a database
|
String[] |
getTableList()
gets the table list of a given database
|
String[][] |
loadTable(String tableName)
loads data from a table of the database
|
void |
startSync(String user,
String pass,
Cell[][] cells,
String tableName,
String url,
Observer observer)
Starts a new sync with database
|
void |
updateTable(String tableName,
String[][] tableData,
String[][] selectedCells,
Cell[][] cells)
updates a database table based on the selected cells
|
void |
updateTableWithDeletion(String tableName,
String[][] tableData,
String[][] selectedCells,
Cell[][] cells)
updates a database table by deleting unselected rows and editing modified rows
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
public DatabaseFacade()
public void createConnection(String url, String user, String pass, String dbName) throws SQLException, ClassNotFoundException, Exception
url
- path to the driveruser
- usernamepass
- passwordSQLException
ClassNotFoundException
Exception
public void exportData(Cell[][] cells, String tableName)
cells
- cells to be exportedtableName
- table's name in the databasepublic String[] getTableList()
public String[][] loadTable(String tableName)
tableName
- name of the tablepublic void startSync(String user, String pass, Cell[][] cells, String tableName, String url, Observer observer)
user
- usernamepass
- username's passwordcells
- cells to be synctableName
- name of the tableurl
- database urlobserver
- the observer objectpublic String[][] cellsTo2dArray(Cell[][] cells)
cells
- selected cells in spreadsheetpublic boolean compareCellsWithDB(String[][] tableData, String[][] selectedCells)
tableData
- content imported from BDselectedCells
- cells selected in the spreadsheetpublic void updateTable(String tableName, String[][] tableData, String[][] selectedCells, Cell[][] cells)
tableName
- target table to be updatedtableData
- 2D array with current table dataselectedCells
- 2D array with selected cells in spreadsheetpublic void updateTableWithDeletion(String tableName, String[][] tableData, String[][] selectedCells, Cell[][] cells)
tableName
- table name in databasetableData
- content from databaseselectedCells
- content sppreadsheetcells
- selected cells