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;
}
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;
}
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;
}
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);
}
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;
}
Aggregations