Search in sources :

Example 26 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.

the class DBSpaceLabelProvider method loadDbData.

public void loadDbData() {
    final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
    final GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            List<String> orignAutoStartDBList = getCubridConfParameterTask.getAutoStartDb(false);
            setDatabaseData(databaseInfoList, orignAutoStartDBList);
            finishedCount++;
            updateToolBar();
            //after get database data ,load volumn data
            loadVolumeData();
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskJobExec.addTask(getDatabaseListTask);
    taskJobExec.addTask(getCubridConfParameterTask);
    String serverName = serverInfo.getServerName();
    String jobName = Messages.taskGetDBInfo + serverName;
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(serverName);
    taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Example 27 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.

the class DBAuthComparator method loadData.

/**
	 * Load the data
	 */
private void loadData() {
    final GetUserListTask getUserTask = new GetUserListTask(database.getDatabaseInfo());
    final GetAllUserAuthorizationsTask getUserAuthTask = new GetAllUserAuthorizationsTask(database.getDatabaseInfo());
    TaskJobExecutor taskExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            final List<UserDetailInfo> userDetailList = new ArrayList<UserDetailInfo>();
            DbUserInfoList userListInfo = getUserTask.getResultModel();
            Map<String, UserDetailInfo> allUserAuthMap = getUserAuthTask.getAllAuthMap();
            if (userListInfo != null) {
                for (DbUserInfo userInfo : userListInfo.getUserList()) {
                    UserDetailInfo userDetailInfo = allUserAuthMap.get(userInfo.getName());
                    if (userDetailInfo == null) {
                        userDetailInfo = new UserDetailInfo();
                        userDetailInfo.setUserName(userInfo.getName());
                    }
                    userDetailList.add(userDetailInfo);
                }
            }
            setTableData(userDetailList);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskExec.addTask(getUserTask);
    taskExec.addTask(getUserAuthTask);
    JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    String jobName = Messages.jobLoadUserData + " - " + "@" + dbName + "@" + serverName;
    taskExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) GetAllUserAuthorizationsTask(com.cubrid.cubridmanager.core.cubrid.user.task.GetAllUserAuthorizationsTask) GetUserListTask(com.cubrid.cubridmanager.core.cubrid.user.task.GetUserListTask) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) List(java.util.List) ArrayList(java.util.ArrayList) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) Map(java.util.Map) UserDetailInfo(com.cubrid.cubridmanager.core.cubrid.user.model.UserDetailInfo)

Example 28 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.

the class TruncateTableAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj)) {
        setEnabled(false);
        return;
    }
    StringBuilder sb = new StringBuilder();
    int len = obj.length;
    final List<String> tableList = new ArrayList<String>();
    CubridDatabase database = null;
    for (int i = 0; i < len; i++) {
        ISchemaNode table = (ISchemaNode) obj[i];
        database = table.getDatabase();
        final String tableName = table.getName();
        tableList.add(tableName);
        if (i < 100) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append(tableName);
        }
    }
    if (len > 100) {
        sb.append("...");
    }
    String message = Messages.bind(Messages.confirmTableDeleteWarn, sb.toString());
    if (!CommonUITool.openConfirmBox(message)) {
        return;
    }
    final TruncateTableTask task = new TruncateTableTask(database.getDatabaseInfo());
    TaskJobExecutor taskExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            CommonUITool.openInformationBox(Messages.msg_information, Messages.resultTableDeleteInformantion);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    String[] tableNames = new String[tableList.size()];
    tableNames = tableList.toArray(tableNames);
    task.setTableName(tableNames);
    taskExec.addTask(task);
    JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    String jobName = Messages.msgTruncateTableJobName + " - " + tableList.toString() + "@" + dbName + "@" + serverName;
    taskExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ArrayList(java.util.ArrayList) TruncateTableTask(com.cubrid.cubridmanager.core.cubrid.table.task.TruncateTableTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 29 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily 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)

Example 30 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.

the class PlanDumpDialog method buttonPressed.

/**
	 * When press button in button bar,call this method
	 * 
	 * @param buttonId the button id
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        if (!verify()) {
            return;
        }
        task = new PlanDumpTask(database.getServer().getServerInfo());
        task.setDbName(database.getName());
        task.setPlanDrop(repairButton.getSelection() ? YesNoType.Y : YesNoType.N);
        String serverName = database.getServer().getName();
        String dbName = database.getName();
        jobName = Messages.titlePlanDumpDialog + " - " + dbName + "@" + serverName;
        TaskJobExecutor taskExec = new CommonTaskJobExec(this);
        taskExec.addTask(task);
        JobFamily jobFamily = new JobFamily();
        jobFamily.setServerName(serverName);
        jobFamily.setDbName(dbName);
        taskExec.schedule(jobName, jobFamily, true, Job.SHORT);
        return;
    }
    super.buttonPressed(buttonId);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) PlanDumpTask(com.cubrid.cubridmanager.core.cubrid.database.task.PlanDumpTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Aggregations

JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)44 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)24 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)19 ITask (com.cubrid.common.core.task.ITask)14 Job (org.eclipse.core.runtime.jobs.Job)14 ArrayList (java.util.ArrayList)12 IStatus (org.eclipse.core.runtime.IStatus)12 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)7 List (java.util.List)7 CheckDirTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckDirTask)6 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)5 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)5 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)5 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 CheckFileTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask)4