Search in sources :

Example 66 with DatabaseInfo

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

the class NodeUtil method findDatabaseInfo.

public static DatabaseInfo findDatabaseInfo(ISchemaNode schemaNode) {
    if (schemaNode == null) {
        LOGGER.error("The schemaNode is a null.");
        return null;
    }
    CubridDatabase cubridDatabase = schemaNode.getDatabase();
    if (cubridDatabase == null) {
        LOGGER.error("The cubridDatabase is a null.");
        return null;
    }
    final DatabaseInfo databaseInfo = cubridDatabase.getDatabaseInfo();
    if (databaseInfo == null) {
        LOGGER.error("The databaseInfo is a null.");
        return null;
    }
    return databaseInfo;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 67 with DatabaseInfo

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

the class NodeUtil method validNode.

public static boolean validNode(ISchemaNode schemaNode) {
    if (schemaNode == null) {
        LOGGER.error("The schemaNode is a null.");
        return false;
    }
    CubridDatabase cubridDatabase = schemaNode.getDatabase();
    if (cubridDatabase == null) {
        LOGGER.error("The cubridDatabase is a null.");
        return false;
    }
    final DatabaseInfo databaseInfo = cubridDatabase.getDatabaseInfo();
    if (databaseInfo == null) {
        LOGGER.error("The databaseInfo is a null.");
        return false;
    }
    return true;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 68 with DatabaseInfo

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

the class ActionSupportUtil method isSupportSinSelCheckDbUser.

/**
	 * 
	 * Return whether support the single selection and the selection type is
	 * equal <code>type</code> and the selection owner is equal to logined
	 * database user
	 * 
	 * @param obj Object
	 * @param type String
	 * @return boolean
	 */
public static boolean isSupportSinSelCheckDbUser(Object obj, String type) {
    if (obj == null) {
        return false;
    }
    Object selectedObj = obj;
    if (obj instanceof Object[]) {
        Object[] objArr = (Object[]) obj;
        if (objArr.length == 1) {
            selectedObj = objArr[0];
        } else {
            return false;
        }
    }
    if (!(selectedObj instanceof ISchemaNode)) {
        return false;
    }
    ISchemaNode node = (ISchemaNode) selectedObj;
    if (type.equals(node.getType())) {
        ISchemaNode schemaNode = (ISchemaNode) selectedObj;
        CubridDatabase database = schemaNode.getDatabase();
        if (isNotRunningAndNotLogin(database)) {
            return false;
        }
        DatabaseInfo dbInfo = database.getDatabaseInfo();
        if (dbInfo == null) {
            LOGGER.error("The database.getDatabaseInfo() is a null.");
            return false;
        }
        DbUserInfo userInfo = dbInfo.getAuthLoginedDbUserInfo();
        if (userInfo == null) {
            LOGGER.error("The dbInfo.getAuthLoginedDbUserInfo() is a null.");
            return false;
        }
        if (userInfo.isDbaAuthority()) {
            return true;
        }
        boolean isSameUser = StringUtil.isEqualIgnoreCase(userInfo.getName(), getOwner(schemaNode));
        if (isSameUser) {
            return true;
        }
    }
    return false;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 69 with DatabaseInfo

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

the class ActionSupportUtil method isSupportMultiSelCheckDbUser.

/**
	 * 
	 * Return whether support the multi selection and all selection type is
	 * equal <code>type</code> and the all selection owner is equal to logined
	 * database user
	 * 
	 * @param obj Object
	 * @param type String
	 * @return boolean
	 */
public static boolean isSupportMultiSelCheckDbUser(Object obj, String type) {
    if (obj instanceof ISchemaNode) {
        ISchemaNode schemaNode = (ISchemaNode) obj;
        if (!type.equals(schemaNode.getType())) {
            return false;
        }
        CubridDatabase database = schemaNode.getDatabase();
        if (isNotRunningAndNotLogin(database)) {
            return false;
        }
        DatabaseInfo dbInfo = database.getDatabaseInfo();
        if (dbInfo == null) {
            LOGGER.error("The database.getDatabaseInfo() is a null.");
            return false;
        }
        DbUserInfo userInfo = dbInfo.getAuthLoginedDbUserInfo();
        if (userInfo == null) {
            LOGGER.error("The dbInfo.getAuthLoginedDbUserInfo() is a null.");
            return false;
        }
        if (userInfo.isDbaAuthority()) {
            return true;
        }
        boolean isSameUser = StringUtil.isEqualIgnoreCase(userInfo.getName(), getOwner(schemaNode));
        if (isSameUser) {
            return true;
        }
    } else if (obj instanceof Object[]) {
        Object[] objArr = (Object[]) obj;
        if (objArr.length == 0) {
            return false;
        }
        CubridDatabase database = null;
        for (Object object : objArr) {
            //Check every object whether support
            if (!isSupportMultiSelCheckDbUser(object, type)) {
                return false;
            }
            //Check whether they are in the same database
            ISchemaNode node = (ISchemaNode) object;
            CubridDatabase db = node.getDatabase();
            if (database == null) {
                database = db;
            } else if (!database.getId().equals(db.getId())) {
                return false;
            }
        }
        //Check the database whether login and running
        if (isNotRunningAndNotLogin(database)) {
            return false;
        }
        return true;
    }
    return false;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 70 with DatabaseInfo

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

the class CopyAndDeleteTaskTest method testCopyDataBase.

public void testCopyDataBase() {
    // task:copydb
    // token:8ec1ab8a91333c78403a39727783958b5f3f25c536c9d92f88b7d31a95a5fadf7926f07dd201b6aa
    // srcdbname:aaa
    // destdbname:dss
    // destdbpath:C:\CUBRID\databases\dss
    // exvolpath:C:\CUBRID\databases\dss
    // logpath:C:\CUBRID\databases\
    // overwrite:n
    // move:n
    // advanced:on
    // open:volume
    // C|/CUBRID/databases/aaa/aaa:C|\CUBRID\databases\dss/dss
    // C|/CUBRID/databases/aaa/aaa_x001:C|\CUBRID\databases\dss/dss_x001
    // C|/CUBRID/databases/aaa/aaa_x002:C|\CUBRID\databases\dss/dss_x002
    // close:volume
    final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
    getDatabaseListTask.execute();
    List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
    DatabaseInfo databaseInfo = null;
    for (DatabaseInfo bean : databaseInfoList) {
        if (bean.getRunningType() == DbRunningType.STANDALONE) {
            databaseInfo = bean;
            break;
        }
    }
    boolean stopDb = false;
    if (databaseInfo == null) {
        stopDb = true;
        databaseInfo = databaseInfoList.get(0);
        CommonUpdateTask stopTask = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
        stopTask.setDbName(databaseInfo.getDbName());
        //stopTask.execute();
        assertEquals(null, stopTask.getErrorMsg());
    }
    // check dir
    CheckDirTask checkDirTask = new CheckDirTask(serverInfo);
    checkDirTask.setDirectory(new String[] { serverPath + getPathSeparator() + "databases" + getPathSeparator() + newdbname });
    //checkDirTask.execute();
    assertEquals(null, checkDirTask.getErrorMsg());
    /*		if (checkDirTask.getNoExistDirectory() != null && checkDirTask.getNoExistDirectory().length > 0) {

		}*/
    CopyDbTask task = new CopyDbTask(serverInfo);
    task.setSrcdbname(databaseInfo.getDbName());
    task.setDestdbname(newdbname);
    task.setDestdbpath(serverPath + getPathSeparator() + "databases" + getPathSeparator() + newdbname);
    task.setExvolpath(serverPath + getPathSeparator() + "databases" + getPathSeparator() + newdbname);
    task.setLogpath(serverPath + getPathSeparator() + "databases" + getPathSeparator() + newdbname);
    task.setOverwrite(YesNoType.N);
    task.setMove(YesNoType.N);
    task.setAdvanced(OnOffType.OFF);
    //task.execute();
    System.out.println("getErrorMsg:" + task.getErrorMsg());
    assertEquals(null, task.getErrorMsg());
    if (stopDb) {
        CommonUpdateTask startTask = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
        startTask.setDbName(databaseInfo.getDbName());
        //startTask.execute();
        assertEquals(null, startTask.getErrorMsg());
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)

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