Search in sources :

Example 41 with JobFamily

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

the class HostUtils method processHostDeleted.

/**
	 * Process resource when delete host
	 * 
	 * @param server CubridServer
	 * @return boolean
	 */
public static boolean processHostDeleted(CubridServer server) {
    if (server == null) {
        LOGGER.debug("The server is a null.");
        return false;
    }
    final JobFamily jobFamily = new JobFamily();
    String serverName = server.getLabel();
    String dbName = JobFamily.ALL_DB;
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    Job[] jobs = Job.getJobManager().find(jobFamily);
    boolean isHaveDashboard = DataGeneratorPool.getInstance().isHasConnection(server.getHostAddress(), server.getMonPort(), server.getUserName());
    // check whether have jobs and monitoring dashboard in this server
    if ((jobs != null && jobs.length > 0) || isHaveDashboard) {
        String msg = Messages.bind(Messages.msgConfirmDeleteHostWithJob, serverName);
        boolean isDisconnectHost = CommonUITool.openConfirmBox(msg);
        if (!isDisconnectHost) {
            return false;
        }
    }
    // check the query editor in this server
    if (!LayoutUtil.checkAllQueryEditor(server)) {
        return false;
    }
    boolean isSaved = server.getServerInfo().isConnected();
    boolean isCloseAll = CubridWorkbenchContrItem.closeAllEditorAndViewInServer(server, isSaved);
    if (!isCloseAll) {
        return false;
    }
    cancelJob(jobFamily);
    QueryOptions.removePref(server.getServerInfo());
    BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(server.getLabel());
    CMHostNodePersistManager.getInstance().removeServer(server);
    return true;
}
Also used : JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Job(org.eclipse.core.runtime.jobs.Job)

Example 42 with JobFamily

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

the class HostUtils method processHostDisconnected.

/**
	 * Process the resource when disconnect host
	 * 
	 * @param server CubridServer
	 * @return boolean
	 */
public static boolean processHostDisconnected(CubridServer server) {
    if (server == null) {
        LOGGER.debug("The server is a null.");
        return false;
    }
    final JobFamily jobFamily = new JobFamily();
    String serverName = server.getLabel();
    String dbName = JobFamily.ALL_DB;
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    Job[] jobs = Job.getJobManager().find(jobFamily);
    boolean isHaveDashboard = DataGeneratorPool.getInstance().isHasConnection(server.getHostAddress(), server.getMonPort(), server.getUserName());
    // check whether have jobs and monitoring dashboard in this server
    if ((jobs != null && jobs.length > 0) || isHaveDashboard) {
        String msg = Messages.bind(Messages.msgConfirmDisconnectHostWithJob, serverName);
        boolean isDisconnectHost = CommonUITool.openConfirmBox(msg);
        if (!isDisconnectHost) {
            return false;
        }
    }
    // check the query editor in this server
    if (!LayoutUtil.checkAllQueryEditor(server)) {
        return false;
    }
    boolean isSaved = server.getServerInfo().isConnected();
    boolean isCloseAll = CubridWorkbenchContrItem.closeAllEditorAndViewInServer(server, isSaved);
    if (!isCloseAll) {
        return false;
    }
    cancelJob(jobFamily);
    server.getLoader().setLoaded(false);
    server.removeAllChild();
    ServerManager.getInstance().setConnected(server.getHostAddress(), server.getMonPort() == null ? 0 : Integer.parseInt(server.getMonPort()), server.getUserName(), false);
    if (!server.isAutoSavePassword()) {
        server.getServerInfo().setUserPassword("");
    }
    return true;
}
Also used : JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Job(org.eclipse.core.runtime.jobs.Job)

Example 43 with JobFamily

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

the class DatabaseUtils method processDatabaseLogout.

/**
	 *
	 * Process the resource when logout database
	 *
	 * @param database CubridDatabase
	 * @return boolean
	 */
public static boolean processDatabaseLogout(CubridDatabase database) {
    final JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    Job[] jobs = Job.getJobManager().find(jobFamily);
    if (jobs.length > 0) {
        boolean isLogout = CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmLogoutDBwithJob, dbName));
        if (!isLogout) {
            return false;
        }
    }
    // check the query editor in this database
    if (!LayoutUtil.checkAllQueryEditor(database)) {
        return false;
    }
    cancelJob(jobFamily);
    database.getLoader().setLoaded(false);
    database.setLogined(false);
    database.removeAllChild();
    if (!database.isAutoSavePassword()) {
        CMDBNodePersistManager.getInstance().deleteDbParameter(database);
    }
    return true;
}
Also used : JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Job(org.eclipse.core.runtime.jobs.Job)

Example 44 with JobFamily

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

the class DatabaseUtils method processDatabaseDeleted.

/**
	 *
	 * Process resource when delete database
	 *
	 * @param database CubridDatabase
	 * @return boolean
	 */
public static boolean processDatabaseDeleted(CubridDatabase database) {
    final JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    Job[] jobs = Job.getJobManager().find(jobFamily);
    if (jobs.length > 0) {
        boolean isLogout = CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmDeleteDBwithJob, dbName));
        if (!isLogout) {
            return false;
        }
    }
    // check the query editor in this database
    if (!LayoutUtil.checkAllQueryEditor(database)) {
        return false;
    }
    cancelJob(jobFamily);
    CubridServer server = database.getServer();
    CMDBNodePersistManager.getInstance().deleteDbParameter(database);
    server.getServerInfo().getAllDatabaseList().remove(database.getName());
    server.getServerInfo().getLoginedUserInfo().removeDatabaseInfo(database.getDatabaseInfo());
    QueryOptions.removePref(database.getDatabaseInfo());
    database.setLogined(false);
    database.removeAllChild();
    return true;
}
Also used : JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Job(org.eclipse.core.runtime.jobs.Job) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

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