public class ControllerUpdate extends Object implements Subject
Constructor and Description |
---|
ControllerUpdate() |
ControllerUpdate(Observer o)
Constructor with observer
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(Observer o)
adds Observer o to arraylist
|
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 |
connect(String url,
String user,
String pass,
String dbName)
creates connection to a database
|
String[][] |
getDBlist()
returns the list of supported databases name
|
String[] |
getTableList()
gets the table list of the selected database
|
String[][] |
loadTable(String tableName)
imports a table from the database
|
void |
notifyObserver(String str) |
void |
removerObserver(Observer o)
removes Observer o from arraylist
|
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 spreadsheets table by deleting unselected cells and editing modified cells
|
public ControllerUpdate()
public ControllerUpdate(Observer o)
o
- Observer objectpublic String[][] getDBlist() throws FileNotFoundException
FileNotFoundException
public void connect(String url, String user, String pass, String dbName) throws Exception
url
- path to driveruser
- usernamepass
- passwordadapteeName
- adaptee class nameException
public void addObserver(Observer o)
addObserver
in interface Subject
o
- Observer objectpublic void removerObserver(Observer o)
removerObserver
in interface Subject
o
- Observer objectpublic void notifyObserver(String str)
notifyObserver
in interface Subject
public String[][] loadTable(String tableName)
tableName
- name of the tablepublic String[] getTableList()
dbName
- name of the databasepublic 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
- table content from databaseselectedCells
- selected content from cleansheetscells
- selected cells