Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
9e668e9b
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,发现更多精彩内容 >>
提交
9e668e9b
编写于
8月 26, 2013
作者:
S
Sam Kim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ACT-1454 Support custom comment types
上级
00014861
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
208 addition
and
1 deletion
+208
-1
modules/activiti-engine/src/main/java/org/activiti/engine/TaskService.java
...engine/src/main/java/org/activiti/engine/TaskService.java
+9
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/TaskServiceImpl.java
...c/main/java/org/activiti/engine/impl/TaskServiceImpl.java
+14
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/AddCommentCmd.java
...main/java/org/activiti/engine/impl/cmd/AddCommentCmd.java
+9
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetTaskCommentsByTypeCmd.java
...rg/activiti/engine/impl/cmd/GetTaskCommentsByTypeCmd.java
+40
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetTypeCommentsCmd.java
...java/org/activiti/engine/impl/cmd/GetTypeCommentsCmd.java
+41
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/CommentEntityManager.java
.../engine/impl/persistence/entity/CommentEntityManager.java
+17
-0
modules/activiti-engine/src/main/java/org/activiti/engine/task/Comment.java
...ngine/src/main/java/org/activiti/engine/task/Comment.java
+3
-0
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/Comment.xml
...main/resources/org/activiti/db/mapping/entity/Comment.xml
+30
-0
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/task/TaskServiceTest.java
...va/org/activiti/engine/test/api/task/TaskServiceTest.java
+45
-0
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/TaskService.java
浏览文件 @
9e668e9b
...
...
@@ -381,6 +381,9 @@ public interface TaskService {
/** Add a comment to a task and/or process instance. */
Comment
addComment
(
String
taskId
,
String
processInstanceId
,
String
message
);
/** Add a comment to a task and/or process instance with a custom type. */
Comment
addComment
(
String
taskId
,
String
processInstanceId
,
String
type
,
String
message
);
/**
* Returns an individual comment with the given id. Returns null if no comment exists with the given id.
*/
...
...
@@ -397,6 +400,12 @@ public interface TaskService {
/** The comments related to the given task. */
List
<
Comment
>
getTaskComments
(
String
taskId
);
/** The comments related to the given task of the given type. */
List
<
Comment
>
getTaskComments
(
String
taskId
,
String
type
);
/** All comments of a given type. */
List
<
Comment
>
getCommentsByType
(
String
type
);
/** The all events related to the given task. */
List
<
Event
>
getTaskEvents
(
String
taskId
);
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/TaskServiceImpl.java
浏览文件 @
9e668e9b
...
...
@@ -40,11 +40,13 @@ import org.activiti.engine.impl.cmd.GetProcessInstanceAttachmentsCmd;
import
org.activiti.engine.impl.cmd.GetProcessInstanceCommentsCmd
;
import
org.activiti.engine.impl.cmd.GetSubTasksCmd
;
import
org.activiti.engine.impl.cmd.GetTaskAttachmentsCmd
;
import
org.activiti.engine.impl.cmd.GetTaskCommentsByTypeCmd
;
import
org.activiti.engine.impl.cmd.GetTaskCommentsCmd
;
import
org.activiti.engine.impl.cmd.GetTaskEventCmd
;
import
org.activiti.engine.impl.cmd.GetTaskEventsCmd
;
import
org.activiti.engine.impl.cmd.GetTaskVariableCmd
;
import
org.activiti.engine.impl.cmd.GetTaskVariablesCmd
;
import
org.activiti.engine.impl.cmd.GetTypeCommentsCmd
;
import
org.activiti.engine.impl.cmd.HasTaskVariableCmd
;
import
org.activiti.engine.impl.cmd.RemoveTaskVariablesCmd
;
import
org.activiti.engine.impl.cmd.ResolveTaskCmd
;
...
...
@@ -277,6 +279,10 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
return
commandExecutor
.
execute
(
new
AddCommentCmd
(
taskId
,
processInstance
,
message
));
}
public
Comment
addComment
(
String
taskId
,
String
processInstance
,
String
type
,
String
message
)
{
return
commandExecutor
.
execute
(
new
AddCommentCmd
(
taskId
,
processInstance
,
type
,
message
));
}
@Override
public
Comment
getComment
(
String
commentId
)
{
return
commandExecutor
.
execute
(
new
GetCommentCmd
(
commentId
));
...
...
@@ -290,6 +296,14 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
public
List
<
Comment
>
getTaskComments
(
String
taskId
)
{
return
commandExecutor
.
execute
(
new
GetTaskCommentsCmd
(
taskId
));
}
public
List
<
Comment
>
getTaskComments
(
String
taskId
,
String
type
)
{
return
commandExecutor
.
execute
(
new
GetTaskCommentsByTypeCmd
(
taskId
,
type
));
}
public
List
<
Comment
>
getCommentsByType
(
String
type
)
{
return
commandExecutor
.
execute
(
new
GetTypeCommentsCmd
(
type
));
}
public
List
<
Event
>
getTaskEvents
(
String
taskId
)
{
return
commandExecutor
.
execute
(
new
GetTaskEventsCmd
(
taskId
));
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/AddCommentCmd.java
浏览文件 @
9e668e9b
...
...
@@ -36,6 +36,7 @@ public class AddCommentCmd implements Command<Comment>{
protected
String
taskId
;
protected
String
processInstanceId
;
protected
String
type
;
protected
String
message
;
public
AddCommentCmd
(
String
taskId
,
String
processInstanceId
,
String
message
)
{
...
...
@@ -44,6 +45,13 @@ public class AddCommentCmd implements Command<Comment>{
this
.
message
=
message
;
}
public
AddCommentCmd
(
String
taskId
,
String
processInstanceId
,
String
type
,
String
message
)
{
this
.
taskId
=
taskId
;
this
.
processInstanceId
=
processInstanceId
;
this
.
type
=
type
;
this
.
message
=
message
;
}
public
Comment
execute
(
CommandContext
commandContext
)
{
// Validate task
...
...
@@ -74,7 +82,7 @@ public class AddCommentCmd implements Command<Comment>{
String
userId
=
Authentication
.
getAuthenticatedUserId
();
CommentEntity
comment
=
new
CommentEntity
();
comment
.
setUserId
(
userId
);
comment
.
setType
(
CommentEntity
.
TYPE_COMMENT
);
comment
.
setType
(
(
type
==
null
)?
CommentEntity
.
TYPE_COMMENT
:
type
);
comment
.
setTime
(
ClockUtil
.
getCurrentTime
());
comment
.
setTaskId
(
taskId
);
comment
.
setProcessInstanceId
(
processInstanceId
);
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetTaskCommentsByTypeCmd.java
0 → 100644
浏览文件 @
9e668e9b
/* 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.activiti.engine.impl.cmd
;
import
java.util.List
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.task.Comment
;
/**
* @author Sam Kim
*/
public
class
GetTaskCommentsByTypeCmd
extends
GetTaskCommentsCmd
{
private
static
final
long
serialVersionUID
=
1L
;
protected
String
type
;
public
GetTaskCommentsByTypeCmd
(
String
taskId
,
String
type
)
{
super
(
taskId
);
this
.
type
=
type
;
}
public
List
<
Comment
>
execute
(
CommandContext
commandContext
)
{
return
commandContext
.
getCommentEntityManager
()
.
findCommentsByTaskIdAndType
(
taskId
,
type
);
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetTypeCommentsCmd.java
0 → 100644
浏览文件 @
9e668e9b
/* 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.activiti.engine.impl.cmd
;
import
java.io.Serializable
;
import
java.util.List
;
import
org.activiti.engine.impl.interceptor.Command
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.task.Comment
;
/**
* @author Sam Kim
*/
public
class
GetTypeCommentsCmd
implements
Command
<
List
<
Comment
>>,
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
protected
String
type
;
public
GetTypeCommentsCmd
(
String
type
)
{
this
.
type
=
type
;
}
public
List
<
Comment
>
execute
(
CommandContext
commandContext
)
{
return
commandContext
.
getCommentEntityManager
()
.
findCommentsByType
(
type
);
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/CommentEntityManager.java
浏览文件 @
9e668e9b
...
...
@@ -13,7 +13,9 @@
package
org.activiti.engine.impl.persistence.entity
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.engine.impl.db.PersistentObject
;
...
...
@@ -42,6 +44,21 @@ public class CommentEntityManager extends AbstractManager {
checkHistoryEnabled
();
return
getDbSqlSession
().
selectList
(
"selectCommentsByTaskId"
,
taskId
);
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
Comment
>
findCommentsByTaskIdAndType
(
String
taskId
,
String
type
)
{
checkHistoryEnabled
();
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"taskId"
,
taskId
);
params
.
put
(
"type"
,
type
);
return
getDbSqlSession
().
selectListWithRawParameter
(
"selectCommentsByTaskIdAndType"
,
params
,
0
,
Integer
.
MAX_VALUE
);
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
Comment
>
findCommentsByType
(
String
type
)
{
checkHistoryEnabled
();
return
getDbSqlSession
().
selectList
(
"selectCommentsByType"
,
type
);
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
Event
>
findEventsByTaskId
(
String
taskId
)
{
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/task/Comment.java
浏览文件 @
9e668e9b
...
...
@@ -39,6 +39,9 @@ public interface Comment {
/** reference to the process instance on which this comment was made */
String
getProcessInstanceId
();
/** reference to the type given to the comment */
String
getType
();
/** the full comment message the user had related to the task and/or process instance
* @see TaskService#getTaskComments(String) */
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/Comment.xml
浏览文件 @
9e668e9b
...
...
@@ -114,6 +114,36 @@
and TYPE_ = 'comment'
order by TIME_ desc
</select>
<select
id=
"selectCommentsByTaskIdAndType"
parameterType=
"java.util.Map"
resultMap=
"commentResultMap"
>
select *
from ${prefix}ACT_HI_COMMENT
where TASK_ID_ = #{taskId,jdbcType=VARCHAR}
and TYPE_ = #{type,jdbcType=VARCHAR}
order by TIME_ desc
</select>
<select
id=
"selectCommentsByTaskIdAndType_postgres"
parameterType=
"java.util.Map"
resultMap=
"commentResultMap_postgres"
>
select *
from ${prefix}ACT_HI_COMMENT
where TASK_ID_ = #{taskId,jdbcType=VARCHAR}
and TYPE_ = #{type,jdbcType=VARCHAR}
order by TIME_ desc
</select>
<select
id=
"selectCommentsByType"
parameterType=
"org.activiti.engine.impl.db.ListQueryParameterObject"
resultMap=
"commentResultMap"
>
select *
from ${prefix}ACT_HI_COMMENT
where TYPE_ = #{parameter,jdbcType=VARCHAR}
order by TIME_ desc
</select>
<select
id=
"selectCommentsByType_postgres"
parameterType=
"org.activiti.engine.impl.db.ListQueryParameterObject"
resultMap=
"commentResultMap_postgres"
>
select *
from ${prefix}ACT_HI_COMMENT
where TYPE_ = #{parameter,jdbcType=VARCHAR}
order by TIME_ desc
</select>
<select
id=
"selectEventsByTaskId"
parameterType=
"org.activiti.engine.impl.db.ListQueryParameterObject"
resultMap=
"commentResultMap"
>
select *
...
...
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/task/TaskServiceTest.java
浏览文件 @
9e668e9b
...
...
@@ -32,6 +32,7 @@ import org.activiti.engine.identity.Group;
import
org.activiti.engine.identity.User
;
import
org.activiti.engine.impl.TaskServiceImpl
;
import
org.activiti.engine.impl.history.HistoryLevel
;
import
org.activiti.engine.impl.persistence.entity.CommentEntity
;
import
org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity
;
import
org.activiti.engine.impl.test.PluggableActivitiTestCase
;
import
org.activiti.engine.runtime.ProcessInstance
;
...
...
@@ -148,6 +149,50 @@ public class TaskServiceTest extends PluggableActivitiTestCase {
taskService
.
deleteTask
(
taskId
,
true
);
}
}
public
void
testCustomTaskComments
()
{
if
(
processEngineConfiguration
.
getHistoryLevel
().
isAtLeast
(
HistoryLevel
.
ACTIVITY
))
{
Task
task
=
taskService
.
newTask
();
task
.
setOwner
(
"johndoe"
);
taskService
.
saveTask
(
task
);
String
taskId
=
task
.
getId
();
identityService
.
setAuthenticatedUserId
(
"johndoe"
);
String
customType1
=
"Type1"
;
String
customType2
=
"Type2"
;
Comment
comment
=
taskService
.
addComment
(
taskId
,
null
,
"This is a regular comment"
);
Comment
customComment1
=
taskService
.
addComment
(
taskId
,
null
,
customType1
,
"This is a custom comment of type Type1"
);
Comment
customComment2
=
taskService
.
addComment
(
taskId
,
null
,
customType1
,
"This is another Type1 comment"
);
Comment
customComment3
=
taskService
.
addComment
(
taskId
,
null
,
customType2
,
"This is another custom comment. Type2 this time!"
);
assertEquals
(
CommentEntity
.
TYPE_COMMENT
,
comment
.
getType
());
assertEquals
(
customType1
,
customComment1
.
getType
());
assertEquals
(
customType2
,
customComment3
.
getType
());
assertNotNull
(
taskService
.
getComment
(
comment
.
getId
()));
assertNotNull
(
taskService
.
getComment
(
customComment1
.
getId
()));
List
<
Comment
>
regularComments
=
taskService
.
getTaskComments
(
taskId
);
assertEquals
(
1
,
regularComments
.
size
());
assertEquals
(
"This is a regular comment"
,
regularComments
.
get
(
0
).
getFullMessage
());
List
<
Event
>
allComments
=
taskService
.
getTaskEvents
(
taskId
);
assertEquals
(
4
,
allComments
.
size
());
List
<
Comment
>
type2Comments
=
taskService
.
getCommentsByType
(
customType2
);
assertEquals
(
1
,
type2Comments
.
size
());
assertEquals
(
"This is another custom comment. Type2 this time!"
,
type2Comments
.
get
(
0
).
getFullMessage
());
List
<
Comment
>
taskTypeComments
=
taskService
.
getTaskComments
(
taskId
,
customType1
);
assertEquals
(
2
,
taskTypeComments
.
size
());
assertEquals
(
"This is another Type1 comment"
,
taskTypeComments
.
get
(
0
).
getFullMessage
());
assertEquals
(
"This is a custom comment of type Type1"
,
taskTypeComments
.
get
(
1
).
getFullMessage
());
// Clean up
taskService
.
deleteTask
(
taskId
,
true
);
}
}
public
void
testTaskAttachments
()
{
if
(
processEngineConfiguration
.
getHistoryLevel
().
isAtLeast
(
HistoryLevel
.
ACTIVITY
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录