Search in sources :

Example 1 with LoadDbTask

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

the class LoadDatabaseDialog method loadDb.

/**
	 * Execute task and load database
	 * 
	 * @param buttonId the button id
	 */
private void loadDb(final int buttonId) {
    TaskJobExecutor taskExcutor = new LoadDbTaskExecutor(buttonId);
    LoadDbTask loadDbTask1 = new LoadDbTask(database.getServer().getServerInfo());
    LoadDbTask loadDbTask2 = new LoadDbTask(database.getServer().getServerInfo());
    loadDbTask1.setDbName(databaseNameText.getText());
    loadDbTask2.setDbName(databaseNameText.getText());
    loadDbTask1.setDbUser(userNameText.getText());
    loadDbTask2.setDbUser(userNameText.getText());
    if (checkSyntaxButton.getSelection()) {
        loadDbTask1.setCheckOption("both");
        loadDbTask2.setCheckOption("both");
    } else {
        loadDbTask1.setCheckOption("load");
        loadDbTask2.setCheckOption("load");
    }
    if (commitPeriodButton.getSelection()) {
        loadDbTask1.setUsedPeriod(true, commitPeriodText.getText());
        loadDbTask2.setUsedPeriod(true, commitPeriodText.getText());
    } else {
        loadDbTask1.setUsedPeriod(false, "");
        loadDbTask2.setUsedPeriod(false, "");
    }
    if (estimatedSizeButton.getSelection()) {
        loadDbTask1.setUsedEstimatedSize(true, estimatedSizeText.getText());
        loadDbTask2.setUsedEstimatedSize(true, estimatedSizeText.getText());
    } else {
        loadDbTask1.setUsedEstimatedSize(false, "");
        loadDbTask2.setUsedEstimatedSize(false, "");
    }
    if (useErrorControlFileButton.getSelection()) {
        loadDbTask1.setUsedErrorContorlFile(true, errorControlFileText.getText());
        loadDbTask2.setUsedErrorContorlFile(true, errorControlFileText.getText());
    } else {
        loadDbTask1.setUsedErrorContorlFile(false, "");
        loadDbTask2.setUsedErrorContorlFile(false, "");
    }
    if (ignoreClassFileButton.getSelection()) {
        loadDbTask1.setUsedIgnoredClassFile(true, ignoredClassFileText.getText());
        loadDbTask2.setUsedIgnoredClassFile(true, ignoredClassFileText.getText());
    } else {
        loadDbTask1.setUsedIgnoredClassFile(false, "");
        loadDbTask2.setUsedIgnoredClassFile(false, "");
    }
    loadDbTask1.setNoUsedOid(oidButton.getSelection());
    loadDbTask2.setNoUsedOid(oidButton.getSelection());
    if (noStatisButton != null) {
        loadDbTask1.setNoUsedStatistics(noStatisButton.getSelection());
        loadDbTask2.setNoUsedStatistics(noStatisButton.getSelection());
    }
    loadDbTask1.setNoUsedLog(false);
    loadDbTask2.setNoUsedLog(false);
    if (selectLoadFileFromListButton.getSelection()) {
        String schemaPath = "";
        String objectPath = "";
        String indexPath = "";
        String triggerPath = "";
        for (int i = 0, n = unloadInfoTable.getItemCount(); i < n; i++) {
            if (unloadInfoTable.getItem(i).getChecked()) {
                String type = unloadInfoTable.getItem(i).getText(0);
                String path = unloadInfoTable.getItem(i).getText(1);
                if (type != null && type.trim().equals("schema")) {
                    schemaPath = path;
                }
                if (type != null && type.trim().equals("object")) {
                    objectPath = path;
                }
                if (type != null && type.trim().equals("index")) {
                    indexPath = path;
                }
                if (type != null && type.trim().equals("trigger")) {
                    triggerPath = path;
                }
            }
        }
        boolean isAddTask1 = false;
        if (schemaPath != null && schemaPath.trim().length() > 0) {
            loadDbTask1.setSchemaPath(schemaPath);
            isAddTask1 = true;
        } else {
            loadDbTask1.setSchemaPath("none");
        }
        if (objectPath != null && objectPath.trim().length() > 0) {
            loadDbTask1.setObjectPath(objectPath);
            isAddTask1 = true;
        } else {
            loadDbTask1.setObjectPath("none");
        }
        if (indexPath != null && indexPath.trim().length() > 0) {
            loadDbTask1.setIndexPath(indexPath);
            isAddTask1 = true;
        } else {
            loadDbTask1.setIndexPath("none");
        }
        boolean isAddTask2 = false;
        if (triggerPath != null && triggerPath.trim().length() > 0) {
            loadDbTask2.setSchemaPath(triggerPath);
            isAddTask2 = true;
        }
        if (isAddTask1) {
            taskExcutor.addTask(loadDbTask1);
        }
        if (isAddTask2) {
            taskExcutor.addTask(loadDbTask2);
        }
    } else if (selectUnloadFileFromSysButton.getSelection()) {
        boolean isAddTask1 = false;
        if (loadSchemaButton.getSelection()) {
            String schemaPath = loadSchemaText.getText();
            loadDbTask1.setSchemaPath(schemaPath);
            isAddTask1 = true;
        } else {
            loadDbTask1.setSchemaPath("none");
        }
        if (loadObjButton.getSelection()) {
            String objPath = loadObjText.getText();
            loadDbTask1.setObjectPath(objPath);
            isAddTask1 = true;
        } else {
            loadDbTask1.setObjectPath("none");
        }
        if (loadIndexButton.getSelection()) {
            String indexPath = loadIndexText.getText();
            loadDbTask1.setIndexPath(indexPath);
            isAddTask1 = true;
        } else {
            loadDbTask1.setIndexPath("none");
        }
        boolean isAddTask2 = false;
        if (loadTriggerButton.getSelection()) {
            String triggerPath = loadTriggerText.getText();
            loadDbTask2.setSchemaPath(triggerPath);
            isAddTask2 = true;
        }
        if (isAddTask1) {
            taskExcutor.addTask(loadDbTask1);
        }
        if (isAddTask2) {
            taskExcutor.addTask(loadDbTask2);
        }
    }
    JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    String jobName = Messages.msgLoadDBRearJobName + " - " + dbName + "@" + serverName;
    taskExcutor.schedule(jobName, jobFamily, true, Job.SHORT);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) LoadDbTask(com.cubrid.cubridmanager.core.cubrid.database.task.LoadDbTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Aggregations

JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)1 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)1 LoadDbTask (com.cubrid.cubridmanager.core.cubrid.database.task.LoadDbTask)1