Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
47e1b0c9
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
47e1b0c9
编写于
6月 08, 2013
作者:
T
Tijs Rademakers
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #79 from henryyan/master
native query for HistoricVariableInstance and HistoricDetail
上级
0174b9f8
fa10a62d
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
279 addition
and
6 deletion
+279
-6
modules/activiti-engine/src/main/java/org/activiti/engine/HistoryService.java
...ine/src/main/java/org/activiti/engine/HistoryService.java
+12
-0
modules/activiti-engine/src/main/java/org/activiti/engine/history/NativeHistoricDetailQuery.java
...rg/activiti/engine/history/NativeHistoricDetailQuery.java
+11
-0
modules/activiti-engine/src/main/java/org/activiti/engine/history/NativeHistoricVariableInstanceQuery.java
...i/engine/history/NativeHistoricVariableInstanceQuery.java
+12
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/HistoryServiceImpl.java
...ain/java/org/activiti/engine/impl/HistoryServiceImpl.java
+13
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/NativeHistoricDetailQueryImpl.java
...g/activiti/engine/impl/NativeHistoricDetailQueryImpl.java
+37
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/NativeHistoricVariableInstanceQueryImpl.java
.../engine/impl/NativeHistoricVariableInstanceQueryImpl.java
+37
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/db/DbSqlSessionFactory.java
...java/org/activiti/engine/impl/db/DbSqlSessionFactory.java
+14
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/HistoricDetailEntityManager.java
.../impl/persistence/entity/HistoricDetailEntityManager.java
+10
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/HistoricVariableInstanceEntityManager.java
...istence/entity/HistoricVariableInstanceEntityManager.java
+10
-0
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricDetail.xml
...sources/org/activiti/db/mapping/entity/HistoricDetail.xml
+24
-0
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricVariableInstance.xml
...g/activiti/db/mapping/entity/HistoricVariableInstance.xml
+24
-0
modules/activiti-engine/src/test/java/org/activiti/engine/test/history/HistoricVariableInstanceTest.java
...iti/engine/test/history/HistoricVariableInstanceTest.java
+75
-5
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/HistoryService.java
浏览文件 @
47e1b0c9
...
...
@@ -28,8 +28,10 @@ import org.activiti.engine.history.HistoricTaskInstanceQuery;
import
org.activiti.engine.history.HistoricVariableInstance
;
import
org.activiti.engine.history.HistoricVariableInstanceQuery
;
import
org.activiti.engine.history.NativeHistoricActivityInstanceQuery
;
import
org.activiti.engine.history.NativeHistoricDetailQuery
;
import
org.activiti.engine.history.NativeHistoricProcessInstanceQuery
;
import
org.activiti.engine.history.NativeHistoricTaskInstanceQuery
;
import
org.activiti.engine.history.NativeHistoricVariableInstanceQuery
;
import
org.activiti.engine.task.IdentityLink
;
/**
...
...
@@ -57,9 +59,19 @@ public interface HistoryService {
/** Creates a new programmatic query to search for {@link HistoricDetail}s. */
HistoricDetailQuery
createHistoricDetailQuery
();
/**
* Returns a new {@link org.activiti.engine.query.NativeQuery} for process definitions.
*/
NativeHistoricDetailQuery
createNativeHistoricDetailQuery
();
/** Creates a new programmatic query to search for {@link HistoricVariableInstance}s. */
HistoricVariableInstanceQuery
createHistoricVariableInstanceQuery
();
/**
* Returns a new {@link org.activiti.engine.query.NativeQuery} for process definitions.
*/
NativeHistoricVariableInstanceQuery
createNativeHistoricVariableInstanceQuery
();
/** Deletes historic task instance. This might be useful for tasks that are
* {@link TaskService#newTask() dynamically created} and then {@link TaskService#complete(String) completed}.
* If the historic task instance doesn't exist, no exception is thrown and the
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/history/NativeHistoricDetailQuery.java
0 → 100644
浏览文件 @
47e1b0c9
package
org.activiti.engine.history
;
import
org.activiti.engine.query.NativeQuery
;
/**
* Allows querying of {@link org.activiti.engine.history.HistoricDetail}s via native (SQL) queries
* @author Henry Yan(http://www.kafeitu.me)
*/
public
interface
NativeHistoricDetailQuery
extends
NativeQuery
<
NativeHistoricDetailQuery
,
HistoricDetail
>
{
}
\ No newline at end of file
modules/activiti-engine/src/main/java/org/activiti/engine/history/NativeHistoricVariableInstanceQuery.java
0 → 100644
浏览文件 @
47e1b0c9
package
org.activiti.engine.history
;
import
org.activiti.engine.query.NativeQuery
;
/**
* Allows querying of {@link org.activiti.engine.history.HistoricVariableInstance}s via native (SQL) queries
* @author Henry Yan(http://www.kafeitu.me)
*/
public
interface
NativeHistoricVariableInstanceQuery
extends
NativeQuery
<
NativeHistoricVariableInstanceQuery
,
HistoricVariableInstance
>
{
}
\ No newline at end of file
modules/activiti-engine/src/main/java/org/activiti/engine/impl/HistoryServiceImpl.java
浏览文件 @
47e1b0c9
...
...
@@ -24,8 +24,10 @@ import org.activiti.engine.history.HistoricProcessInstanceQuery;
import
org.activiti.engine.history.HistoricTaskInstanceQuery
;
import
org.activiti.engine.history.HistoricVariableInstanceQuery
;
import
org.activiti.engine.history.NativeHistoricActivityInstanceQuery
;
import
org.activiti.engine.history.NativeHistoricDetailQuery
;
import
org.activiti.engine.history.NativeHistoricProcessInstanceQuery
;
import
org.activiti.engine.history.NativeHistoricTaskInstanceQuery
;
import
org.activiti.engine.history.NativeHistoricVariableInstanceQuery
;
import
org.activiti.engine.impl.cmd.DeleteHistoricProcessInstanceCmd
;
import
org.activiti.engine.impl.cmd.DeleteHistoricTaskInstanceCmd
;
import
org.activiti.engine.impl.cmd.GetHistoricIdentityLinksForTaskCmd
;
...
...
@@ -53,10 +55,20 @@ public class HistoryServiceImpl extends ServiceImpl implements HistoryService {
return
new
HistoricDetailQueryImpl
(
commandExecutor
);
}
@Override
public
NativeHistoricDetailQuery
createNativeHistoricDetailQuery
()
{
return
new
NativeHistoricDetailQueryImpl
(
commandExecutor
);
}
public
HistoricVariableInstanceQuery
createHistoricVariableInstanceQuery
()
{
return
new
HistoricVariableInstanceQueryImpl
(
commandExecutor
);
}
@Override
public
NativeHistoricVariableInstanceQuery
createNativeHistoricVariableInstanceQuery
()
{
return
new
NativeHistoricVariableInstanceQueryImpl
(
commandExecutor
);
}
public
void
deleteHistoricTaskInstance
(
String
taskId
)
{
commandExecutor
.
execute
(
new
DeleteHistoricTaskInstanceCmd
(
taskId
));
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/NativeHistoricDetailQueryImpl.java
0 → 100644
浏览文件 @
47e1b0c9
package
org.activiti.engine.impl
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.history.HistoricDetail
;
import
org.activiti.engine.history.NativeHistoricDetailQuery
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.interceptor.CommandExecutor
;
public
class
NativeHistoricDetailQueryImpl
extends
AbstractNativeQuery
<
NativeHistoricDetailQuery
,
HistoricDetail
>
implements
NativeHistoricDetailQuery
{
private
static
final
long
serialVersionUID
=
1L
;
public
NativeHistoricDetailQueryImpl
(
CommandContext
commandContext
)
{
super
(
commandContext
);
}
public
NativeHistoricDetailQueryImpl
(
CommandExecutor
commandExecutor
)
{
super
(
commandExecutor
);
}
//results ////////////////////////////////////////////////////////////////
public
List
<
HistoricDetail
>
executeList
(
CommandContext
commandContext
,
Map
<
String
,
Object
>
parameterMap
,
int
firstResult
,
int
maxResults
)
{
return
commandContext
.
getHistoricDetailEntityManager
()
.
findHistoricDetailsByNativeQuery
(
parameterMap
,
firstResult
,
maxResults
);
}
public
long
executeCount
(
CommandContext
commandContext
,
Map
<
String
,
Object
>
parameterMap
)
{
return
commandContext
.
getHistoricDetailEntityManager
()
.
findHistoricDetailCountByNativeQuery
(
parameterMap
);
}
}
\ No newline at end of file
modules/activiti-engine/src/main/java/org/activiti/engine/impl/NativeHistoricVariableInstanceQueryImpl.java
0 → 100644
浏览文件 @
47e1b0c9
package
org.activiti.engine.impl
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.history.HistoricVariableInstance
;
import
org.activiti.engine.history.NativeHistoricVariableInstanceQuery
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.interceptor.CommandExecutor
;
public
class
NativeHistoricVariableInstanceQueryImpl
extends
AbstractNativeQuery
<
NativeHistoricVariableInstanceQuery
,
HistoricVariableInstance
>
implements
NativeHistoricVariableInstanceQuery
{
private
static
final
long
serialVersionUID
=
1L
;
public
NativeHistoricVariableInstanceQueryImpl
(
CommandContext
commandContext
)
{
super
(
commandContext
);
}
public
NativeHistoricVariableInstanceQueryImpl
(
CommandExecutor
commandExecutor
)
{
super
(
commandExecutor
);
}
//results ////////////////////////////////////////////////////////////////
public
List
<
HistoricVariableInstance
>
executeList
(
CommandContext
commandContext
,
Map
<
String
,
Object
>
parameterMap
,
int
firstResult
,
int
maxResults
)
{
return
commandContext
.
getHistoricVariableInstanceEntityManager
()
.
findHistoricVariableInstancesByNativeQuery
(
parameterMap
,
firstResult
,
maxResults
);
}
public
long
executeCount
(
CommandContext
commandContext
,
Map
<
String
,
Object
>
parameterMap
)
{
return
commandContext
.
getHistoricVariableInstanceEntityManager
()
.
findHistoricVariableInstanceCountByNativeQuery
(
parameterMap
);
}
}
\ No newline at end of file
modules/activiti-engine/src/main/java/org/activiti/engine/impl/db/DbSqlSessionFactory.java
浏览文件 @
47e1b0c9
...
...
@@ -99,6 +99,13 @@ public class DbSqlSessionFactory implements SessionFactory {
addDatabaseSpecificStatement
(
"db2"
,
"selectHistoricProcessInstanceByNativeQuery"
,
"selectHistoricProcessInstanceByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"db2"
,
"selectHistoricTaskInstanceByNativeQuery"
,
"selectHistoricTaskInstanceByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"db2"
,
"selectTaskByNativeQuery"
,
"selectTaskByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"db2"
,
"selectProcessDefinitionByNativeQuery"
,
"selectProcessDefinitionByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"db2"
,
"selectDeploymentByNativeQuery"
,
"selectDeploymentByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"db2"
,
"selectGroupByNativeQuery"
,
"selectGroupByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"db2"
,
"selectUserByNativeQuery"
,
"selectUserByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"db2"
,
"selectModelByNativeQuery"
,
"selectModelByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"db2"
,
"selectHistoricDetailByNativeQuery"
,
"selectHistoricDetailByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"db2"
,
"selectHistoricVariableInstanceByNativeQuery"
,
"selectHistoricVariableInstanceByNativeQuery_mssql_or_db2"
);
// mssql
databaseSpecificLimitBeforeStatements
.
put
(
"mssql"
,
"SELECT SUB.* FROM ("
);
...
...
@@ -112,6 +119,13 @@ public class DbSqlSessionFactory implements SessionFactory {
addDatabaseSpecificStatement
(
"mssql"
,
"selectHistoricProcessInstanceByNativeQuery"
,
"selectHistoricProcessInstanceByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"mssql"
,
"selectHistoricTaskInstanceByNativeQuery"
,
"selectHistoricTaskInstanceByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"mssql"
,
"selectTaskByNativeQuery"
,
"selectTaskByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"mssql"
,
"selectProcessDefinitionByNativeQuery"
,
"selectProcessDefinitionByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"mssql"
,
"selectDeploymentByNativeQuery"
,
"selectDeploymentByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"mssql"
,
"selectGroupByNativeQuery"
,
"selectGroupByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"mssql"
,
"selectUserByNativeQuery"
,
"selectUserByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"mssql"
,
"selectModelByNativeQuery"
,
"selectModelByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"mssql"
,
"selectHistoricDetailByNativeQuery"
,
"selectHistoricDetailByNativeQuery_mssql_or_db2"
);
addDatabaseSpecificStatement
(
"mssql"
,
"selectHistoricVariableInstanceByNativeQuery"
,
"selectHistoricVariableInstanceByNativeQuery_mssql_or_db2"
);
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/HistoricDetailEntityManager.java
浏览文件 @
47e1b0c9
...
...
@@ -14,6 +14,7 @@
package
org.activiti.engine.impl.persistence.entity
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.history.HistoricDetail
;
import
org.activiti.engine.impl.HistoricDetailQueryImpl
;
...
...
@@ -60,4 +61,13 @@ public class HistoricDetailEntityManager extends AbstractManager {
}
}
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
HistoricDetail
>
findHistoricDetailsByNativeQuery
(
Map
<
String
,
Object
>
parameterMap
,
int
firstResult
,
int
maxResults
)
{
return
getDbSqlSession
().
selectListWithRawParameter
(
"selectHistoricDetailByNativeQuery"
,
parameterMap
,
firstResult
,
maxResults
);
}
public
long
findHistoricDetailCountByNativeQuery
(
Map
<
String
,
Object
>
parameterMap
)
{
return
(
Long
)
getDbSqlSession
().
selectOne
(
"selectHistoricDetailCountByNativeQuery"
,
parameterMap
);
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/HistoricVariableInstanceEntityManager.java
浏览文件 @
47e1b0c9
...
...
@@ -14,6 +14,7 @@
package
org.activiti.engine.impl.persistence.entity
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.history.HistoricVariableInstance
;
import
org.activiti.engine.impl.HistoricVariableInstanceQueryImpl
;
...
...
@@ -74,4 +75,13 @@ public class HistoricVariableInstanceEntityManager extends AbstractManager {
}
}
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
HistoricVariableInstance
>
findHistoricVariableInstancesByNativeQuery
(
Map
<
String
,
Object
>
parameterMap
,
int
firstResult
,
int
maxResults
)
{
return
getDbSqlSession
().
selectListWithRawParameter
(
"selectHistoricVariableInstanceByNativeQuery"
,
parameterMap
,
firstResult
,
maxResults
);
}
public
long
findHistoricVariableInstanceCountByNativeQuery
(
Map
<
String
,
Object
>
parameterMap
)
{
return
(
Long
)
getDbSqlSession
().
selectOne
(
"selectHistoricVariableInstanceCountByNativeQuery"
,
parameterMap
);
}
}
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricDetail.xml
浏览文件 @
47e1b0c9
...
...
@@ -155,4 +155,28 @@
</where>
</sql>
<select
id=
"selectHistoricDetailByNativeQuery"
parameterType=
"java.util.Map"
resultMap=
"historicDetailResultMap"
>
<if
test=
"resultType == 'LIST_PAGE'"
>
${limitBefore}
</if>
${sql}
<if
test=
"resultType == 'LIST_PAGE'"
>
${limitAfter}
</if>
</select>
<select
id=
"selectHistoricDetailByNativeQuery_mssql_or_db2"
parameterType=
"java.util.Map"
resultMap=
"historicDetailResultMap"
>
<if
test=
"resultType == 'LIST_PAGE'"
>
${limitBeforeNativeQuery}
</if>
${sql}
<if
test=
"resultType == 'LIST_PAGE'"
>
${limitAfter}
</if>
</select>
<select
id=
"selectHistoricDetailCountByNativeQuery"
parameterType=
"java.util.Map"
resultType=
"long"
>
${sql}
</select>
</mapper>
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricVariableInstance.xml
浏览文件 @
47e1b0c9
...
...
@@ -170,4 +170,28 @@
select * from ${prefix}ACT_HI_VARINST where ID_ = #{variableInstanceId}
</select>
<select
id=
"selectHistoricVariableInstanceByNativeQuery"
parameterType=
"java.util.Map"
resultMap=
"historicProcessVariableResultMap"
>
<if
test=
"resultType == 'LIST_PAGE'"
>
${limitBefore}
</if>
${sql}
<if
test=
"resultType == 'LIST_PAGE'"
>
${limitAfter}
</if>
</select>
<select
id=
"selectHistoricVariableInstanceByNativeQuery_mssql_or_db2"
parameterType=
"java.util.Map"
resultMap=
"historicProcessVariableResultMap"
>
<if
test=
"resultType == 'LIST_PAGE'"
>
${limitBeforeNativeQuery}
</if>
${sql}
<if
test=
"resultType == 'LIST_PAGE'"
>
${limitAfter}
</if>
</select>
<select
id=
"selectHistoricVariableInstanceCountByNativeQuery"
parameterType=
"java.util.Map"
resultType=
"long"
>
${sql}
</select>
</mapper>
modules/activiti-engine/src/test/java/org/activiti/engine/test/history/HistoricVariableInstanceTest.java
浏览文件 @
47e1b0c9
...
...
@@ -13,16 +13,11 @@
package
org.activiti.engine.test.history
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.HistoryService
;
import
org.activiti.engine.ProcessEngineConfiguration
;
import
org.activiti.engine.RuntimeService
;
import
org.activiti.engine.history.HistoricActivityInstance
;
import
org.activiti.engine.history.HistoricDetail
;
import
org.activiti.engine.history.HistoricVariableInstance
;
...
...
@@ -314,4 +309,79 @@ public class HistoricVariableInstanceTest extends AbstractActivitiTestCase {
}
@Deployment
(
resources
=
"org/activiti/engine/test/history/HistoricVariableInstanceTest.testSimple.bpmn20.xml"
)
public
void
testNativeHistoricVariableInstanceQuery
()
{
assertEquals
(
"ACT_HI_VARINST"
,
managementService
.
getTableName
(
HistoricVariableInstance
.
class
));
assertEquals
(
"ACT_HI_VARINST"
,
managementService
.
getTableName
(
HistoricVariableInstanceEntity
.
class
));
String
tableName
=
managementService
.
getTableName
(
HistoricVariableInstance
.
class
);
String
baseQuerySql
=
"SELECT * FROM "
+
tableName
;
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
variables
.
put
(
"var1"
,
"value1"
);
variables
.
put
(
"var2"
,
"value2"
);
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
"myProc"
,
variables
);
assertNotNull
(
processInstance
);
assertEquals
(
3
,
historyService
.
createNativeHistoricVariableInstanceQuery
().
sql
(
baseQuerySql
).
list
().
size
());
String
sqlWithConditions
=
baseQuerySql
+
" where NAME_ = #{name}"
;
assertEquals
(
"test123"
,
historyService
.
createNativeHistoricVariableInstanceQuery
().
sql
(
sqlWithConditions
)
.
parameter
(
"name"
,
"myVar"
).
singleResult
().
getValue
());
sqlWithConditions
=
baseQuerySql
+
" where NAME_ like #{name}"
;
assertEquals
(
2
,
historyService
.
createNativeHistoricVariableInstanceQuery
().
sql
(
sqlWithConditions
)
.
parameter
(
"name"
,
"var%"
).
list
().
size
());
// paging
assertEquals
(
3
,
historyService
.
createNativeHistoricVariableInstanceQuery
().
sql
(
baseQuerySql
).
listPage
(
0
,
3
).
size
());
assertEquals
(
2
,
historyService
.
createNativeHistoricVariableInstanceQuery
().
sql
(
baseQuerySql
).
listPage
(
1
,
3
).
size
());
assertEquals
(
2
,
historyService
.
createNativeHistoricVariableInstanceQuery
().
sql
(
sqlWithConditions
)
.
parameter
(
"name"
,
"var%"
).
listPage
(
0
,
2
).
size
());
}
@Deployment
(
resources
=
"org/activiti/engine/test/history/HistoricVariableInstanceTest.testSimple.bpmn20.xml"
)
public
void
testNativeHistoricDetailQuery
()
{
assertEquals
(
"ACT_HI_DETAIL"
,
managementService
.
getTableName
(
HistoricDetail
.
class
));
assertEquals
(
"ACT_HI_DETAIL"
,
managementService
.
getTableName
(
HistoricVariableUpdate
.
class
));
String
tableName
=
managementService
.
getTableName
(
HistoricDetail
.
class
);
String
baseQuerySql
=
"SELECT * FROM "
+
tableName
;
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
variables
.
put
(
"var1"
,
"value1"
);
variables
.
put
(
"var2"
,
"value2"
);
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
"myProc"
,
variables
);
assertNotNull
(
processInstance
);
assertEquals
(
3
,
historyService
.
createNativeHistoricDetailQuery
().
sql
(
baseQuerySql
).
list
().
size
());
String
sqlWithConditions
=
baseQuerySql
+
" where NAME_ = #{name} and TYPE_ = #{type}"
;
assertNotNull
(
historyService
.
createNativeHistoricDetailQuery
().
sql
(
sqlWithConditions
)
.
parameter
(
"name"
,
"myVar"
).
parameter
(
"type"
,
"VariableUpdate"
).
singleResult
());
sqlWithConditions
=
baseQuerySql
+
" where NAME_ like #{name}"
;
assertEquals
(
2
,
historyService
.
createNativeHistoricDetailQuery
().
sql
(
sqlWithConditions
)
.
parameter
(
"name"
,
"var%"
).
list
().
size
());
Task
task
=
taskService
.
createTaskQuery
().
singleResult
();
Map
<
String
,
String
>
formDatas
=
new
HashMap
<
String
,
String
>();
formDatas
.
put
(
"field1"
,
"field value 1"
);
formDatas
.
put
(
"field2"
,
"field value 2"
);
formService
.
submitTaskFormData
(
task
.
getId
(),
formDatas
);
String
countSql
=
"select count(*) from "
+
tableName
+
" where TYPE_ = #{type} and PROC_INST_ID_ = #{pid}"
;
assertEquals
(
2
,
historyService
.
createNativeHistoricDetailQuery
().
sql
(
countSql
)
.
parameter
(
"type"
,
"FormProperty"
).
parameter
(
"pid"
,
processInstance
.
getId
()).
count
());
// paging
assertEquals
(
3
,
historyService
.
createNativeHistoricDetailQuery
().
sql
(
baseQuerySql
).
listPage
(
0
,
3
).
size
());
assertEquals
(
3
,
historyService
.
createNativeHistoricDetailQuery
().
sql
(
baseQuerySql
).
listPage
(
1
,
3
).
size
());
sqlWithConditions
=
baseQuerySql
+
" where TYPE_ = #{type} and PROC_INST_ID_ = #{pid}"
;
assertEquals
(
2
,
historyService
.
createNativeHistoricDetailQuery
().
sql
(
sqlWithConditions
)
.
parameter
(
"type"
,
"FormProperty"
).
parameter
(
"pid"
,
processInstance
.
getId
()).
listPage
(
0
,
2
).
size
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录