Search in sources :

Example 1 with ParamDumpTask

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

the class CubridDatabaseLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(final ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = (CubridDatabase) parent;
        database.getDatabaseInfo().clear();
        if (!database.isLogined()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        //when refresh,firstly check whether this database exist
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
        ParamDumpTask paramDumpTask = null;
        if (CompatibleUtil.isSupportGetParamDump(serverInfo)) {
            paramDumpTask = new ParamDumpTask(serverInfo);
            paramDumpTask.setDbName(database.getLabel());
            paramDumpTask.setBoth(YesNoType.N);
        }
        monitorCancel(monitor, new ITask[] { getDatabaseListTask, paramDumpTask });
        getDatabaseListTask.execute();
        if (!checkResult(getDatabaseListTask, monitor)) {
            parent.removeAllChild();
            return;
        }
        List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
        ParamDumpInfo paraDumpInfo = null;
        if (paramDumpTask != null) {
            paramDumpTask.execute();
            if (!checkResult(paramDumpTask, monitor)) {
                parent.removeAllChild();
                return;
            }
            paraDumpInfo = paramDumpTask.getContent();
        }
        String databaseName = database.getLabel();
        boolean isExist = false;
        for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
            DatabaseInfo dbInfo = databaseInfoList.get(i);
            if (dbInfo.getDbName().equalsIgnoreCase(databaseName)) {
                database.setRunningType(dbInfo.getRunningType());
                isExist = true;
            }
        }
        if (!isExist) {
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(Messages.errDatabaseNoExist);
                    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
                    TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
                    if (treeViewer != null) {
                        CommonUITool.refreshNavigatorTree(treeViewer, parent.getParent());
                    }
                }
            });
            setLoaded(true);
            return;
        }
        if (!loadReplication(parent, monitor)) {
            setLoaded(true);
            return;
        }
        // add tables folder
        addTableFolder(monitor, database);
        // add views folder
        addViewFolder(monitor, database);
        // add serials folder
        addSerialFolder(monitor, database);
        // add user folder
        addUserFolder(monitor, database);
        // add triggers folder
        addTriggerFolder(monitor, database);
        // add stored procedure folder
        addProcedureFolder(monitor, database);
        // add job automation folder
        addJobAutoFolder(monitor, database);
        // add database space folder
        addSpaceFolder(monitor, database);
        // set parameter dump information
        database.getDatabaseInfo().setParaDumpInfo(paraDumpInfo);
        // set charset info
        setDbCollation(database);
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ParamDumpInfo(com.cubrid.cubridmanager.core.cubrid.database.model.ParamDumpInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) ParamDumpTask(com.cubrid.cubridmanager.core.cubrid.database.task.ParamDumpTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) Display(org.eclipse.swt.widgets.Display)

Example 2 with ParamDumpTask

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

the class ParamDumpDialog 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 ParamDumpTask(database.getServer().getServerInfo());
        task.setDbName(database.getName());
        task.setBoth(repairButton.getSelection() ? YesNoType.Y : YesNoType.N);
        String serverName = database.getServer().getName();
        String dbName = database.getName();
        jobName = Messages.titleParamDumpDialog + " - " + 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) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) ParamDumpTask(com.cubrid.cubridmanager.core.cubrid.database.task.ParamDumpTask)

Aggregations

ParamDumpTask (com.cubrid.cubridmanager.core.cubrid.database.task.ParamDumpTask)2 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)1 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)1 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 ParamDumpInfo (com.cubrid.cubridmanager.core.cubrid.database.model.ParamDumpInfo)1 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Display (org.eclipse.swt.widgets.Display)1