Search in sources :

Example 76 with CubridDatabase

use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.

the class ActionSupportUtil method hasAdminPermissionOnStopState.

/**
	 * Whether having cubrid manager's administrative permissions on stop state
	 *
	 * @param obj ISchemaNode or ISchemaNode[]
	 * @return boolean
	 */
public static boolean hasAdminPermissionOnStopState(Object obj) {
    if (!ActionSupportUtil.hasAdminPermission(obj)) {
        return false;
    }
    ISchemaNode node = (ISchemaNode) obj;
    CubridDatabase database = node.getDatabase();
    if (database == null) {
        return false;
    }
    if (database.getRunningType() != DbRunningType.STANDALONE) {
        return false;
    }
    return true;
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 77 with CubridDatabase

use of com.cubrid.common.ui.spi.model.CubridDatabase 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 78 with CubridDatabase

use of com.cubrid.common.ui.spi.model.CubridDatabase 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 79 with CubridDatabase

use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.

the class JavaType method getJavaPOJOString.

/**
	 * Get the POJO String, The type of schemaNode should be table or class
	 * 
	 * @param schemaNode
	 * @return the POJO String
	 */
public static String getJavaPOJOString(Connection connection, DefaultSchemaNode schemaNode) {
    CubridDatabase database = schemaNode.getDatabase();
    String tableName = schemaNode.getName();
    SchemaInfo schemaInfo = null;
    if (connection == null) {
        schemaInfo = database.getDatabaseInfo().getSchemaInfo(tableName);
    } else {
        schemaInfo = database.getDatabaseInfo().getSchemaInfo(connection, tableName);
    }
    if (schemaInfo == null) {
        com.cubrid.common.ui.spi.util.CommonUITool.openErrorBox(Messages.bind(Messages.errGetSchemaInfo, tableName));
        LOGGER.debug("Can't get the SchemaInfo:" + tableName);
        return "";
    }
    POJOTemplate template = new POJOTemplate();
    template.setTableName(tableName);
    StringBuffer typeDeclareSB = new StringBuffer();
    typeDeclareSB.append("public class ");
    typeDeclareSB.append(getUpperName(tableName));
    template.setTypeDeclare(typeDeclareSB.toString());
    StringBuffer annotationSB = new StringBuffer();
    annotationSB.append("/**" + NEW_LINE);
    annotationSB.append(" * Table name : " + tableName + NEW_LINE);
    annotationSB.append(" * Generated by CUBRID Tools." + NEW_LINE);
    annotationSB.append(" */");
    template.setAnnotation(annotationSB.toString());
    /* Attributes */
    for (DBAttribute dbAttribute : schemaInfo.getAttributes()) {
        POJOAttribute attribute = getPOJOAttribute(dbAttribute, true);
        if (attribute != null) {
            template.getAttributes().add(attribute);
        }
    }
    /* Class Attribute */
    for (DBAttribute dbAttribute : schemaInfo.getClassAttributes()) {
        POJOAttribute attribute = getPOJOAttribute(dbAttribute, true);
        if (attribute != null) {
            template.getAttributes().add(attribute);
        }
    }
    return getJavaPOJOString(template);
}
Also used : DBAttribute(com.cubrid.common.core.common.model.DBAttribute) POJOTemplate(com.cubrid.cubridmanager.core.cubrid.table.model.POJOTemplate) POJOAttribute(com.cubrid.cubridmanager.core.cubrid.table.model.POJOAttribute) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 80 with CubridDatabase

use of com.cubrid.common.ui.spi.model.CubridDatabase 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)

Aggregations

CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)278 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)104 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)79 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)67 ArrayList (java.util.ArrayList)45 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)43 TreeViewer (org.eclipse.jface.viewers.TreeViewer)42 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)36 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)33 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)30 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)29 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)28 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)25 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)22 Shell (org.eclipse.swt.widgets.Shell)22 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)19 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)18 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)18 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)18 ITask (com.cubrid.common.core.task.ITask)17