use of com.cubrid.cubridmanager.core.cubrid.table.task.UpdateStatisticsTask in project cubrid-manager by CUBRID.
the class UpdateStatisticsAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
// FIXME move this logic to core module
List<String> sqlList = new ArrayList<String>();
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < obj.length; i++) {
ISchemaNode schemaNode = (ISchemaNode) obj[i];
String tableName = schemaNode.getParent().getName();
int partitionNameLoc = schemaNode.getName().lastIndexOf("__p__");
if (partitionNameLoc == -1) {
continue;
}
partitionNameLoc += 5;
String partitionName = schemaNode.getName().substring(partitionNameLoc);
String sql = "ALTER TABLE " + QuerySyntax.escapeKeyword(tableName) + " ANALYZE PARTITION " + QuerySyntax.escapeKeyword(partitionName);
sqlList.add(sql);
buffer.append(",");
buffer.append(schemaNode.getName());
}
String str = buffer.toString().replaceFirst(",", "");
if (CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmUpdateStatis, str))) {
DefaultSchemaNode node = (DefaultSchemaNode) obj[0];
String taskName = Messages.bind(Messages.updateStatisTaskName, node.getName());
TaskExecutor executor = new CommonTaskExec(taskName);
UpdateStatisticsTask task = new UpdateStatisticsTask(node.getDatabase().getDatabaseInfo());
task.setSqlList(sqlList);
executor.addTask(task);
new ExecTaskWithProgress(executor).exec();
if (executor.isSuccess()) {
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.msgSuccessUpdateStatis);
}
}
}
Aggregations