Search in sources :

Example 86 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class ServiceDashboardEditor method setDbData.

/**
	 * Set Server Database Info
	 */
private void setDbData(ServiceDashboardInfo sDashInfo, List<DatabaseInfo> databaseInfoList) {
    int databaseOn = 0, databaseOff = 0;
    if (databaseInfoList != null) {
        for (DatabaseInfo dbInfo : databaseInfoList) {
            if (dbInfo.getRunningType() == DbRunningType.CS)
                databaseOn += 1;
        }
        databaseOff = databaseInfoList.size() - databaseOn;
    }
    sDashInfo.setDatabaseOn(databaseOn);
    sDashInfo.setDatabaseOff(databaseOff);
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)

Example 87 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class SetDistributorDbInfoDialog method checkDatabaseExist.

/**
	 * Check whether the database exist
	 * 
	 * @param dbName the database name
	 * @return <code>true</code> if already exist;<code>false</code> otherwise
	 */
private boolean checkDatabaseExist(String dbName) {
    boolean isDatabaseExist = false;
    List<DatabaseInfo> databaseInfoList = hostNode.getDatabaseInfoList();
    for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
        DatabaseInfo databaseInfo = databaseInfoList.get(i);
        if (dbName.equalsIgnoreCase(databaseInfo.getDbName())) {
            isDatabaseExist = true;
            break;
        }
    }
    if (!isDatabaseExist) {
        List<LeafNode> childNodeList = hostNode.getChildNodeList();
        for (int i = 0; childNodeList != null && i < childNodeList.size(); i++) {
            LeafNode node = childNodeList.get(i);
            if (dbName.equalsIgnoreCase(node.getName()) && !dbName.equals(distributorNode.getDbName())) {
                isDatabaseExist = true;
                break;
            }
        }
    }
    return isDatabaseExist;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode)

Example 88 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class SetHostInfoDialog method connect.

/**
	 * connect the host
	 * 
	 * @param buttonId int
	 */
private void connect(final int buttonId) {
    final String ip = ipText.getText();
    final String port = portText.getText();
    final String userName = userNameText.getText();
    final String password = passwordText.getText();
    boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
    if (isConnected && hostInfo != null) {
        ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
        if (!serverInfo.getLoginedUserInfo().isAdmin()) {
            CommonUITool.openErrorBox(Messages.bind(Messages.errInvalidUser, ip));
            return;
        }
        hostInfo.setIp(ip);
        hostInfo.setPort(port);
        hostInfo.setUserName(userName);
        hostInfo.setPassword(password);
        hostInfo.setName(ip + ":" + port);
        List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
        hostInfo.setDatabaseInfoList(databaseInfoList);
        hostInfo.setDbPath(serverInfo.getEnvInfo().getDatabaseDir());
        hostInfo.setOsInfoType(serverInfo.getServerOsInfo());
        setReturnCode(buttonId);
        close();
        return;
    }
    if (!isConnected) {
        final ServerInfo serverInfo = new ServerInfo();
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(userName);
        serverInfo.setUserPassword(password);
        TaskExecutor taskExcutor = new ConnectHostTaskExecutor(serverInfo, buttonId);
        MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
        taskExcutor.addTask(monitoringTask);
        GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
        taskExcutor.addTask(getEnvInfoTask);
        GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
        taskExcutor.addTask(getCMConfParameterTask);
        GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
        taskExcutor.addTask(getDatabaseListTask);
        new ExecTaskWithProgress(taskExcutor).exec(true, true);
    }
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)

Example 89 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class SelectDatabasePage method modifyText.

/**
	 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
	 * @param event ModifyEvent
	 */
public void modifyText(ModifyEvent event) {
    String mdbName = masterDbNameCombo.getText();
    String dbaPassword = dbaPasswordText.getText();
    String serverPort = serverPortText.getText();
    boolean isValidPassword = dbaPassword.length() >= 4 && dbaPassword.indexOf(" ") < 0;
    boolean isValidDbName = ValidateUtil.isValidDBName(mdbName);
    boolean isLogined = false;
    if (isValidDbName && databaseInfoList != null) {
        for (int i = 0; i < databaseInfoList.size(); i++) {
            DatabaseInfo dbInfo = databaseInfoList.get(i);
            if (mdbName.equalsIgnoreCase(dbInfo.getDbName())) {
                isLogined = dbInfo.isLogined() && !dbInfo.getAuthLoginedDbUserInfo().getName().equalsIgnoreCase("dba");
                if (dbInfo.isLogined() && isValidPassword) {
                    isValidPassword = dbaPassword.equals(dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword());
                }
                break;
            }
        }
    }
    boolean isValidPort = ValidateUtil.isNumber(serverPort);
    if (isValidPort) {
        int portVal = Integer.parseInt(serverPort);
        if (portVal < 1024 || portVal > 65535) {
            isValidPort = false;
        }
    }
    boolean isValidHost = host != null && host.isValid();
    if (!isValidHost) {
        setErrorMessage(Messages.errInvalidHostInfo);
        setPageComplete(false);
        return;
    }
    if (!isMdbExist) {
        setErrorMessage(Messages.bind(Messages.errNoMdb, mdbName));
        setPageComplete(false);
        return;
    }
    if (isLogined) {
        setErrorMessage(Messages.bind(Messages.errInvalidDbUser, mdbName));
        setPageComplete(false);
        return;
    }
    if (!isValidDbName) {
        setErrorMessage(Messages.errDatabaseName);
        setPageComplete(false);
        return;
    }
    if (!isValidPassword) {
        setErrorMessage(Messages.errDbaPassword);
        setPageComplete(false);
        return;
    }
    if (!isValidPort) {
        setErrorMessage(Messages.errReplServerPort);
        setPageComplete(false);
        return;
    }
    setErrorMessage(null);
    setPageComplete(true);
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)

Example 90 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class CubridDatabaseLoader method setDbCollation.

private void setDbCollation(CubridDatabase database) {
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    boolean supportCharset = CompatibleUtil.isSupportCreateDBByCharset(databaseInfo);
    if (!supportCharset || !databaseInfo.getServerInfo().isConnected()) {
        return;
    }
    GetDbCollationTask getDbCollationTask = new GetDbCollationTask(databaseInfo);
    getDbCollationTask.execute();
    if (getDbCollationTask.isSuccess()) {
        databaseInfo.setCollation(getDbCollationTask.getCollation());
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) GetDbCollationTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetDbCollationTask)

Aggregations

DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)188 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)79 ArrayList (java.util.ArrayList)45 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)31 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)30 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)30 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)25 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)23 ITask (com.cubrid.common.core.task.ITask)20 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)18 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)18 Map (java.util.Map)15 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)14 HashMap (java.util.HashMap)14 Composite (org.eclipse.swt.widgets.Composite)14 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)13 GridLayout (org.eclipse.swt.layout.GridLayout)13