Search in sources :

Example 16 with GetAllClassListTask

use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask in project cubrid-manager by CUBRID.

the class GetInfoDataTask method initDDLText.

/**
	 * Initial DDL text
	 */
private void initDDLText() {
    final StringBuffer sqlScript = new StringBuffer();
    if (!isTable) {
        /*Get class info*/
        GetAllClassListTask getAllClassListTask = new GetAllClassListTask(schemaNode.getDatabase().getDatabaseInfo());
        getAllClassListTask.setTableName(schemaNode.getName());
        getAllClassListTask.getClassInfoTaskExcute();
        /*If failed*/
        if (getAllClassListTask.getErrorMsg() != null || getAllClassListTask.isCancel()) {
            LOGGER.error(getAllClassListTask.getErrorMsg());
            openError(Messages.bind(Messages.titleGetMetaDataErr, schemaNode.getName()), Messages.bind(Messages.msgGetMetaDataErr, schemaNode.getName(), getAllClassListTask.getErrorMsg()));
            return;
        }
        ClassInfo classInfo = getAllClassListTask.getClassInfo();
        /*Get view column*/
        GetViewAllColumnsTask getAllDBVclassTask = new GetViewAllColumnsTask(schemaNode.getDatabase().getDatabaseInfo());
        getAllDBVclassTask.setClassName(schemaNode.getName());
        getAllDBVclassTask.getAllVclassListTaskExcute();
        /*If failed*/
        if (getAllDBVclassTask.getErrorMsg() != null || getAllDBVclassTask.isCancel()) {
            LOGGER.error(getAllDBVclassTask.getErrorMsg());
            openError(Messages.bind(Messages.titleGetMetaDataErr, schemaNode.getName()), Messages.bind(Messages.msgGetMetaDataErr, schemaNode.getName(), getAllClassListTask.getErrorMsg()));
            return;
        }
        /*Get query list*/
        List<String> vclassList = getAllDBVclassTask.getAllVclassList();
        List<Map<String, String>> queryListData = new ArrayList<Map<String, String>>();
        for (String sql : vclassList) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("0", sql);
            queryListData.add(map);
        }
        /*Get all attribute*/
        GetAllAttrTask getAllAttrTask = new GetAllAttrTask(schemaNode.getDatabase().getDatabaseInfo());
        getAllAttrTask.setClassName(schemaNode.getName());
        getAllAttrTask.getAttrList();
        /*If failed*/
        if (getAllAttrTask.getErrorMsg() != null) {
            LOGGER.error(getAllAttrTask.getErrorMsg());
            openError(Messages.bind(Messages.titleGetMetaDataErr, schemaNode.getName()), Messages.bind(Messages.msgGetMetaDataErr, schemaNode.getName(), getAllClassListTask.getErrorMsg()));
            return;
        }
        List<DBAttribute> attrList = getAllAttrTask.getAllAttrList();
        viewColListData = GetInfoDataUtil.getViewColMapList(attrList);
        sqlScript.append(GetInfoDataUtil.getViewCreateSQLScript(false, schemaNode.getDatabase(), classInfo, schemaNode.getName(), viewColListData, queryListData));
    } else {
        String ddl = SQLGenerateUtils.getCreateSQL(schemaNode);
        sqlScript.append(ddl == null ? "" : ddl);
    }
    Display.getDefault().syncExec(new Runnable() {

        public void run() {
            objectInfoComposite.getSqlText().setText(sqlScript.toString());
        }
    });
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GetAllClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask) GetViewAllColumnsTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetViewAllColumnsTask) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) HashMap(java.util.HashMap) Map(java.util.Map) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo) GetAllAttrTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllAttrTask)

Example 17 with GetAllClassListTask

use of com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask in project cubrid-manager by CUBRID.

the class CQBUserEditor method loadData.

/**
	 * Load data
	 *
	 * @return <code>true</code> if it is successfully;<code>false</code>
	 *         otherwise
	 */
public boolean loadData() {
    Connection con = null;
    try {
        con = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), false);
        final GetUserListTask task = new GetUserListTask(database.getDatabaseInfo(), con);
        final GetAllClassListTask classInfoTask = new GetAllClassListTask(database.getDatabaseInfo(), con);
        final GetAllPartitionClassTask partitionTask = new GetAllPartitionClassTask(database.getDatabaseInfo(), con);
        execTask(new ITask[] { task, classInfoTask, partitionTask });
        GetUserAuthorizationsTask privilegeTask = new GetUserAuthorizationsTask(database.getDatabaseInfo(), con);
        try {
            for (DbUserInfo userInfo : userListInfo.getUserList()) {
                if (userInfo.getName().equals(userName)) {
                    userInfo.setUserAuthorizations(privilegeTask.getUserAuthorizations(userInfo.getName()));
                }
            }
        } catch (Exception e) {
            LOGGER.error("get user failed", e);
        }
        initial();
    } catch (Exception e) {
        LOGGER.error(e.getMessage());
    } finally {
        QueryUtil.freeQuery(con);
    }
    return true;
}
Also used : GetUserListTask(com.cubrid.cubridmanager.core.cubrid.user.task.GetUserListTask) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) GetAllClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask) Connection(java.sql.Connection) GetAllPartitionClassTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask) GetUserAuthorizationsTask(com.cubrid.cubridmanager.core.cubrid.user.task.GetUserAuthorizationsTask) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

GetAllClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask)17 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)10 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)7 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)7 GetAllAttrTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllAttrTask)6 GetViewAllColumnsTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetViewAllColumnsTask)6 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)5 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)5 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)5 GetAllPartitionClassTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask)5 ITask (com.cubrid.common.core.task.ITask)4 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)4 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)4 GetUserListTask (com.cubrid.cubridmanager.core.cubrid.user.task.GetUserListTask)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)3 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)3 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)3 DbUserInfoList (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList)3 GetUserAuthorizationsTask (com.cubrid.cubridmanager.core.cubrid.user.task.GetUserAuthorizationsTask)3