public void run() {
try{
// Export the DB content as DBunit dataset
DatabaseExporter databaseExporter = new DatabaseExporter();
databaseExporter.fullExport(destinationFolder);
// stop and hide the animation
busyLabelPanel.getJxBusyLabel().setBusy(false);
busyLabelPanel.getJxBusyLabel().setVisible(false);
operationResultLabel.setText("Operation Executed Successfully");
operationResultLabel.setFont(new Font("Serif", Font.BOLD, 15));
operationResultLabel.setForeground(Color.GREEN);
}catch (Exception ex) {
if(Log4jManager.IS_LOGGING_CONFIGURED)
logger.fatal("Error executing the full DB export, cause: ",ex);
// stop and hide the animation
busyLabelPanel.getJxBusyLabel().setBusy(false);
busyLabelPanel.getJxBusyLabel().setVisible(false);
operationResultLabel.setText("Error during the export operation: "+ex.getMessage());
operationResultLabel.setFont(new Font("Serif", Font.BOLD, 15));
operationResultLabel.setForeground(Color.RED);
}
}
};
fullExportDatabaseThread.start();
}
}
/**
* Perform a partial export of the chosen tables using the provided query to extract the data-set for each selected table
*
* IMPORTANT: due to editable table before exoprt the partial dataset is necessary remove the focus from the table, because
* a change made by the user in a specific cell is applied to the table model only when the editable cell lose the focus
* or the user has pressed the return key
*
*/
if (e.getActionCommand().equals("Partial Export"))
{
if (!busyLabelPanel.getJxBusyLabel().isEnabled()){
busyLabelPanel.getJxBusyLabel().setEnabled(true);
}
if (busyLabelPanel.getJxBusyLabel().isBusy()) {
busyLabelPanel.getJxBusyLabel().setBusy(false);
busyLabelPanel.getJxBusyLabel().setVisible(false);
}else {
busyLabelPanel.getJxBusyLabel().setBusy(true);
busyLabelPanel.getJxBusyLabel().setVisible(true);
final String destinationFolder = this.exportFolderValue.getText();
//only the table list that the user want export
final List<TableInfoPartialExportBean> filteredTableToExport = new ArrayList<TableInfoPartialExportBean>();
//---- Get the table model to obtain the user choice: ie the table to export
PartialExportTableModel tableModel = (PartialExportTableModel)this.getPartialDatabaseExportPanel().getTableSelectionGrid().getModel();
List<TableInfoPartialExportBean> fullTableList = tableModel.getRowList();
for(int i=0;i<fullTableList.size();i++)
{
if(fullTableList.get(i).isIncludeTable())
{
TableInfoPartialExportBean tableInfoPartialExport = new TableInfoPartialExportBean();
tableInfoPartialExport.setTableName(fullTableList.get(i).getTableName());
tableInfoPartialExport.setExportQuery(fullTableList.get(i).getExportQuery());
filteredTableToExport.add(tableInfoPartialExport);
}
}
//-------------
//The exporting operation can be a long task: open a separate Thread
Thread partialExportDatabaseThread = new Thread() {
public void run() {
try{
// Export the DB content as DBunit dataset
DatabaseExporter databaseExporter = new DatabaseExporter();
databaseExporter.partialExport(destinationFolder, filteredTableToExport);
// stop and hide the animation
busyLabelPanel.getJxBusyLabel().setBusy(false);
busyLabelPanel.getJxBusyLabel().setVisible(false);