Search in sources :

Example 1 with GetDbBackupInfoTask

use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDbBackupInfoTask in project cubrid-manager by CUBRID.

the class BackupDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    final CubridDatabase database = node.getDatabase();
    final BackupDatabaseDialog dialog = new BackupDatabaseDialog(getShell());
    dialog.setDatabase(database);
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(Messages.loadDbBackupInfoTaskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (task instanceof GetDbBackupInfoTask) {
                    GetDbBackupInfoTask getDbBackupInfoTask = (GetDbBackupInfoTask) task;
                    dialog.setDbBackupInfo(getDbBackupInfoTask.getDbBackupInfo());
                } else if (task instanceof GetCubridConfParameterTask) {
                    GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
                    Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
                    Map<String, String> commonParas = confParas.get(ConfConstants.COMMON_SECTION_NAME);
                    Map<String, String> dbParas = confParas.get("[@" + database.getLabel() + "]");
                    String str = dbParas == null ? null : dbParas.get(ConfConstants.REPLICATION);
                    boolean isReplication = "yes".equals(str);
                    if (!isReplication) {
                        str = commonParas == null ? null : commonParas.get(ConfConstants.REPLICATION);
                        isReplication = "yes".equals(str);
                    }
                    dialog.setReplication(isReplication);
                }
            }
            return true;
        }
    };
    ServerInfo serverInfo = database.getServer().getServerInfo();
    GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
    taskExcutor.addTask(getCubridConfParameterTask);
    GetDbBackupInfoTask getDbBackupInfoTask = new GetDbBackupInfoTask(serverInfo);
    getDbBackupInfoTask.setDbName(database.getLabel());
    taskExcutor.addTask(getDbBackupInfoTask);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        dialog.open();
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetDbBackupInfoTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDbBackupInfoTask) BackupDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.BackupDatabaseDialog) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) Map(java.util.Map)

Aggregations

ITask (com.cubrid.common.core.task.ITask)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)1 GetDbBackupInfoTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDbBackupInfoTask)1 BackupDatabaseDialog (com.cubrid.cubridmanager.ui.cubrid.database.dialog.BackupDatabaseDialog)1 Map (java.util.Map)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Shell (org.eclipse.swt.widgets.Shell)1