use of com.cubrid.cubridmanager.ui.logs.dialog.CasRunnerConfigDialog in project cubrid-manager by CUBRID.
the class ExecuteSqlLogAction method run.
/**
* Open dialog
*/
public void run() {
Object[] obj = this.getSelectedObj();
DefaultCubridNode node = null;
LogInfo logInfo = null;
node = (DefaultCubridNode) obj[0];
String targetBroker = node.getParent().getParent().getLabel();
logInfo = (LogInfo) node.getAdapter(LogInfo.class);
List<String> allDatabaseList = node.getServer().getServerInfo().getAllDatabaseList();
BrokerInfos brokerInfos = node.getServer().getServerInfo().getBrokerInfos();
CasRunnerConfigDialog casRunnerConfigDialog = new CasRunnerConfigDialog(getShell());
casRunnerConfigDialog.setBrokerInfos(brokerInfos);
casRunnerConfigDialog.setAllDatabaseList(allDatabaseList);
casRunnerConfigDialog.setLogInfo(logInfo);
casRunnerConfigDialog.setTargetBroker(targetBroker);
casRunnerConfigDialog.setExecwithFile(true);
casRunnerConfigDialog.create();
if (casRunnerConfigDialog.open() == Dialog.OK) {
final GetExecuteCasRunnerResultTask task = new GetExecuteCasRunnerResultTask(((DefaultCubridNode) obj[0]).getServer().getServerInfo());
task.setBrokerName(CasRunnerConfigDialog.getBrokerName());
task.setUserName(CasRunnerConfigDialog.getUserName());
task.setPasswd(CasRunnerConfigDialog.getPassword());
task.setNumThread(CasRunnerConfigDialog.getNumThread());
task.setRepeatCount(casRunnerConfigDialog.getNumRepeatCount());
String isShowqueryresult = "";
if (casRunnerConfigDialog.isShowqueryresult()) {
isShowqueryresult = "yes";
} else {
isShowqueryresult = "no";
}
task.setShowQueryResult(isShowqueryresult);
String isShowqueryplan = "";
if (casRunnerConfigDialog.isShowqueryplan()) {
isShowqueryplan = "yes";
} else {
isShowqueryplan = "no";
}
task.setShowQueryResult(isShowqueryplan);
task.setDbName(CasRunnerConfigDialog.getDbname());
task.setExecuteLogFile("yes");
task.setLogFile(logInfo.getPath());
TaskExecutor taskExcutor = new CommonTaskExec(Messages.loadSqlLogExecResultTaskName);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).exec();
if (!taskExcutor.isSuccess()) {
return;
}
GetExecuteCasRunnerResultInfo getExecuteCasRunnerResultInfo = (GetExecuteCasRunnerResultInfo) task.getContent();
StringBuffer result = new StringBuffer("");
if (getExecuteCasRunnerResultInfo.getResult() != null) {
for (int i = 0, n = getExecuteCasRunnerResultInfo.getResult().size(); i < n; i++) {
result.append(getExecuteCasRunnerResultInfo.getResult().get(i) + "\n");
}
}
CasRunnerResultDialog casRunnerResultDialog = new CasRunnerResultDialog(getShell());
casRunnerResultDialog.setResult(result);
casRunnerResultDialog.open();
}
}
Aggregations