use of com.cubrid.cubridmanager.core.logs.task.GetExecuteCasRunnerContentResultTask in project cubrid-manager by CUBRID.
the class SqlLogAnalyzeResultDialog method createGroupQuery.
/**
* This method initializes groupQuery
*/
private void createGroupQuery() {
GridData gridData22 = new GridData(GridData.FILL_HORIZONTAL);
gridData22.heightHint = 26;
gridData22.widthHint = 122;
GridData gridData21 = new GridData(GridData.FILL_BOTH);
gridData21.horizontalSpan = 3;
gridData21.widthHint = 432;
gridData21.heightHint = 150;
GridData gridData11 = new GridData(GridData.FILL_BOTH);
gridData11.horizontalSpan = 3;
gridData11.widthHint = 432;
gridData11.heightHint = 250;
GridLayout gridLayout2 = new GridLayout();
gridLayout2.numColumns = 3;
gridLayout2.horizontalSpacing = 45;
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.verticalSpan = 2;
Group groupQuery = new Group(composite, SWT.NONE);
groupQuery.setText("");
groupQuery.setLayout(gridLayout2);
groupQuery.setLayoutData(gridData);
Label label1 = new Label(groupQuery, SWT.NONE);
label1.setText(Messages.labelLogContents);
textQuery = new Text(groupQuery, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
textQuery.setEditable(true);
textQuery.setLayoutData(gridData11);
Label label2 = new Label(groupQuery, SWT.NONE);
label2.setText(Messages.labelExecuteResult);
textQueryResult = new Text(groupQuery, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
textQueryResult.setLayoutData(gridData21);
buttonRunOriginalQuery = new Button(groupQuery, SWT.NONE);
buttonRunOriginalQuery.setEnabled(false);
buttonRunOriginalQuery.setText(Messages.buttonExecuteOriginalQuery);
Label dummy5 = new Label(groupQuery, SWT.NONE);
dummy5.setLayoutData(gridData22);
buttonRunOriginalQuery.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String queryString = textQuery.getText();
LogInfo logInfo = null;
String targetBroker = null;
if (node.getId().indexOf("Sql log/") < 0) {
targetBroker = node.getParent().getLabel();
} else {
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.setLogstring(queryString);
casRunnerConfigDialog.setBrokerInfos(brokerInfos);
casRunnerConfigDialog.setAllDatabaseList(allDatabaseList);
casRunnerConfigDialog.setLogInfo(logInfo);
casRunnerConfigDialog.setTargetBroker(targetBroker);
casRunnerConfigDialog.create();
if (casRunnerConfigDialog.open() == Dialog.OK) {
final GetExecuteCasRunnerContentResultTask task = new GetExecuteCasRunnerContentResultTask(node.getServer().getServerInfo());
task.setBrokerName(CasRunnerConfigDialog.getBrokerName());
task.setUserName(CasRunnerConfigDialog.getUserName());
task.setPasswd(CasRunnerConfigDialog.getPassword());
task.setNumThread(CasRunnerConfigDialog.getNumThread());
task.setRepeatCount(casRunnerConfigDialog.getNumRepeatCount());
String isShowqueryresult = "";
String isShowqueryplan = "";
if (casRunnerConfigDialog.isShowqueryresult()) {
isShowqueryresult = "yes";
isShowqueryplan = casRunnerConfigDialog.isShowqueryresult() ? "yes" : "no";
} else {
isShowqueryresult = "no";
isShowqueryplan = "no";
}
task.setShowQueryResult(isShowqueryresult);
task.setShowQueryResult(isShowqueryplan);
task.setDbName(CasRunnerConfigDialog.getDbname());
task.setExecuteLogFile("no");
String[] queryStringArr = queryString.split("\\r\\n");
task.setLogstring(queryStringArr);
TaskExecutor taskExecutor = new CommonTaskExec(Messages.loadSqlLogExecResultTaskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
GetExecuteCasRunnerResultInfo getExecuteCasRunnerResultInfo = (GetExecuteCasRunnerResultInfo) task.getContent();
StringBuffer result = new StringBuffer("");
for (int i = 0, n = getExecuteCasRunnerResultInfo.getResult().size(); i < n; i++) {
result.append(getExecuteCasRunnerResultInfo.getResult().get(i) + "\n");
}
String logPath = null;
String totalResultNum = null;
logPath = getExecuteCasRunnerResultInfo.getQueryResultFile();
totalResultNum = getExecuteCasRunnerResultInfo.getQueryResultFileNum();
if (queryString.length() > 0) {
textQueryResult.setText(result.toString());
if (casRunnerConfigDialog.isShowqueryresult()) {
CasRunnerResultViewDialog casRunnerResultViewDialog = new CasRunnerResultViewDialog(getShell());
casRunnerResultViewDialog.create();
casRunnerResultViewDialog.connectInit(logPath, CasRunnerConfigDialog.getDbname(), node);
casRunnerResultViewDialog.setTotalResultNum(Integer.parseInt(totalResultNum));
casRunnerResultViewDialog.getShell().setSize(665, 555);
casRunnerResultViewDialog.open();
}
}
}
}
}
});
buttonSaveToFile = new Button(groupQuery, SWT.NONE);
buttonSaveToFile.setEnabled(false);
buttonSaveToFile.setText(Messages.buttonSaveLogString);
buttonSaveToFile.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String savedFilename = saveAsFile();
if (isBlank(savedFilename)) {
return;
}
if (analyzeCasLogResultList == null || analyzeCasLogResultList.getLogFileInfoList() == null) {
return;
}
AnalyzeCasLogResultInfo analyzeCasLogResultInfo = (AnalyzeCasLogResultInfo) (analyzeCasLogResultList.getLogFileInfoList().get(currentResultIndex));
if (savedFilename.length() > 0) {
analyzeCasLogResultInfo.setSavedFileName(savedFilename);
}
}
});
}
Aggregations