Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
003fb6e8
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
003fb6e8
编写于
5月 07, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
QMDB: history reading
上级
642c24e5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
128 addition
and
18 deletion
+128
-18
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/qm/QMControllerImpl.java
...re/src/org/jkiss/dbeaver/runtime/qm/QMControllerImpl.java
+44
-9
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/querylog/QueryLogViewer.java
...rg/jkiss/dbeaver/ui/controls/querylog/QueryLogViewer.java
+4
-4
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMEventBrowser.java
....model/src/org/jkiss/dbeaver/model/qm/QMEventBrowser.java
+2
-5
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMEventCriteria.java
...model/src/org/jkiss/dbeaver/model/qm/QMEventCriteria.java
+78
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/qm/QMControllerImpl.java
浏览文件 @
003fb6e8
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-201
7
Serge Rider (serge@jkiss.org)
* Copyright (C) 2010-201
8
Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -18,11 +18,12 @@ package org.jkiss.dbeaver.runtime.qm;
import
org.eclipse.core.runtime.Adapters
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.qm.*
;
import
org.jkiss.dbeaver.model.qm.meta.*
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.utils.ArrayUtils
;
import
org.jkiss.utils.CommonUtils
;
import
java.lang.reflect.InvocationHandler
;
...
...
@@ -30,6 +31,7 @@ import java.lang.reflect.InvocationTargetException;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Proxy
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
/**
...
...
@@ -168,17 +170,41 @@ public class QMControllerImpl implements QMController {
@Override
public
QMEventCursor
getQueryHistoryCursor
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
String
containerId
,
@Nullable
String
sessionId
,
@Nullable
String
searchString
)
@NotNull
QMEventCriteria
criteria
)
throws
DBException
{
if
(
CommonUtils
.
isEmpty
(
searchString
))
{
return
new
QMUtils
.
ListCursorImpl
(
metaHandler
.
getPastEvents
());
List
<
QMMetaEvent
>
pastEvents
=
metaHandler
.
getPastEvents
();
if
(
criteria
.
getObjectTypes
()
!=
null
||
criteria
.
getQueryTypes
()
!=
null
)
{
// Filter by query type and object type
for
(
Iterator
<
QMMetaEvent
>
iter
=
pastEvents
.
iterator
();
iter
.
hasNext
();
)
{
QMMetaEvent
event
=
iter
.
next
();
if
(
criteria
.
getObjectTypes
()
!=
null
)
{
if
(!
matchesObjectType
(
event
.
getObject
(),
criteria
.
getObjectTypes
()))
{
iter
.
remove
();
continue
;
}
}
if
(
criteria
.
getQueryTypes
()
!=
null
)
{
QMMStatementInfo
statementInfo
=
null
;
if
(
event
.
getObject
()
instanceof
QMMStatementInfo
)
{
statementInfo
=
(
QMMStatementInfo
)
event
.
getObject
();
}
else
if
(
event
.
getObject
()
instanceof
QMMStatementExecuteInfo
)
{
statementInfo
=
((
QMMStatementExecuteInfo
)
event
.
getObject
()).
getStatement
();
}
if
(
statementInfo
!=
null
&&
!
ArrayUtils
.
contains
(
criteria
.
getQueryTypes
(),
((
QMMStatementInfo
)
event
.
getObject
()).
getPurpose
()))
{
iter
.
remove
();
}
}
}
}
if
(
CommonUtils
.
isEmpty
(
criteria
.
getSearchString
()))
{
return
new
QMUtils
.
ListCursorImpl
(
pastEvents
);
}
else
{
searchString
=
searchString
.
toLowerCase
();
String
searchString
=
criteria
.
getSearchString
()
.
toLowerCase
();
List
<
QMMetaEvent
>
filtered
=
new
ArrayList
<>();
for
(
QMMetaEvent
event
:
metaHandler
.
getPastEvents
()
)
{
for
(
QMMetaEvent
event
:
pastEvents
)
{
if
(
event
.
getObject
().
getText
().
toLowerCase
().
contains
(
searchString
))
{
filtered
.
add
(
event
);
}
...
...
@@ -186,5 +212,14 @@ public class QMControllerImpl implements QMController {
return
new
QMUtils
.
ListCursorImpl
(
filtered
);
}
}
private
boolean
matchesObjectType
(
QMMObject
object
,
QMObjectType
[]
objectTypes
)
{
if
(
object
instanceof
QMMSessionInfo
)
return
ArrayUtils
.
contains
(
objectTypes
,
QMObjectType
.
session
);
else
if
(
object
instanceof
QMMTransactionInfo
||
object
instanceof
QMMTransactionSavepointInfo
)
return
ArrayUtils
.
contains
(
objectTypes
,
QMObjectType
.
txn
);
else
return
ArrayUtils
.
contains
(
objectTypes
,
QMObjectType
.
query
);
}
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/querylog/QueryLogViewer.java
浏览文件 @
003fb6e8
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -620,8 +619,9 @@ public class QueryLogViewer extends Viewer implements QMMetaListener, DBPPrefere
try
{
QMEventBrowser
eventBrowser
=
QMUtils
.
getEventBrowser
();
if
(
eventBrowser
!=
null
)
{
String
searchPattern
=
CommonUtils
.
isEmptyTrimmed
(
searchString
)
?
null
:
searchString
.
trim
();
try
(
QMEventCursor
cursor
=
eventBrowser
.
getQueryHistoryCursor
(
monitor
,
null
,
null
,
searchPattern
))
{
QMEventCriteria
criteria
=
new
QMEventCriteria
();
criteria
.
setSearchString
(
CommonUtils
.
isEmptyTrimmed
(
searchString
)
?
null
:
searchString
.
trim
());
try
(
QMEventCursor
cursor
=
eventBrowser
.
getQueryHistoryCursor
(
monitor
,
criteria
))
{
while
(
events
.
size
()
<
this
.
entriesPerPage
&&
cursor
.
hasNextEvent
(
monitor
))
{
events
.
add
(
cursor
.
nextEvent
(
monitor
));
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMEventBrowser.java
浏览文件 @
003fb6e8
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-201
7
Serge Rider (serge@jkiss.org)
* Copyright (C) 2010-201
8
Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -18,7 +18,6 @@
package
org.jkiss.dbeaver.model.qm
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
...
...
@@ -29,9 +28,7 @@ public interface QMEventBrowser {
QMEventCursor
getQueryHistoryCursor
(
@NotNull
DBRProgressMonitor
monitor
,
@Nullable
String
containerId
,
@Nullable
String
sessionId
,
@Nullable
String
searchString
)
@NotNull
QMEventCriteria
criteria
)
throws
DBException
;
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/QMEventCriteria.java
0 → 100644
浏览文件 @
003fb6e8
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.model.qm
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
/**
* QM event criteria
*/
public
class
QMEventCriteria
{
@Nullable
String
containerId
;
@Nullable
String
sessionId
;
@Nullable
QMObjectType
[]
objectTypes
;
@Nullable
DBCExecutionPurpose
[]
queryTypes
;
@Nullable
String
searchString
;
public
String
getContainerId
()
{
return
containerId
;
}
public
void
setContainerId
(
String
containerId
)
{
this
.
containerId
=
containerId
;
}
public
String
getSessionId
()
{
return
sessionId
;
}
public
void
setSessionId
(
String
sessionId
)
{
this
.
sessionId
=
sessionId
;
}
public
QMObjectType
[]
getObjectTypes
()
{
return
objectTypes
;
}
public
void
setObjectTypes
(
QMObjectType
[]
objectTypes
)
{
this
.
objectTypes
=
objectTypes
;
}
public
DBCExecutionPurpose
[]
getQueryTypes
()
{
return
queryTypes
;
}
public
void
setQueryTypes
(
DBCExecutionPurpose
[]
queryTypes
)
{
this
.
queryTypes
=
queryTypes
;
}
public
String
getSearchString
()
{
return
searchString
;
}
public
void
setSearchString
(
String
searchString
)
{
this
.
searchString
=
searchString
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录