Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
c31849e5
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,发现更多精彩内容 >>
提交
c31849e5
编写于
3月 11, 2011
作者:
T
tombaeyens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ACT-688 Add comments to tasks and process instances
上级
ce004913
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
328 addition
and
8 deletion
+328
-8
modules/activiti-engine/src/main/java/org/activiti/engine/FormService.java
...engine/src/main/java/org/activiti/engine/FormService.java
+6
-2
modules/activiti-engine/src/main/java/org/activiti/engine/TaskService.java
...engine/src/main/java/org/activiti/engine/TaskService.java
+2
-0
modules/activiti-engine/src/main/java/org/activiti/engine/form/Comment.java
...ngine/src/main/java/org/activiti/engine/form/Comment.java
+5
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/FormServiceImpl.java
...c/main/java/org/activiti/engine/impl/FormServiceImpl.java
+10
-4
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/AddCommentCmd.java
...main/java/org/activiti/engine/impl/cmd/AddCommentCmd.java
+53
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteTaskCmd.java
...main/java/org/activiti/engine/impl/cmd/DeleteTaskCmd.java
+3
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetProcessInstanceCommentsCmd.java
...tiviti/engine/impl/cmd/GetProcessInstanceCommentsCmd.java
+41
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetTaskCommentsCmd.java
...java/org/activiti/engine/impl/cmd/GetTaskCommentsCmd.java
+41
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/form/CommentEntity.java
...ain/java/org/activiti/engine/impl/form/CommentEntity.java
+85
-0
modules/activiti-engine/src/main/resources/org/activiti/db/ibatis/history.mapping.xml
...main/resources/org/activiti/db/ibatis/history.mapping.xml
+42
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.h2.upgradestep.53.to.54.identity.sql
.../db/upgrade/activiti.h2.upgradestep.53.to.54.identity.sql
+2
-1
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/task/TaskServiceTest.java
...va/org/activiti/engine/test/api/task/TaskServiceTest.java
+38
-1
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/FormService.java
浏览文件 @
c31849e5
...
...
@@ -73,8 +73,12 @@ public interface FormService {
/** Completes a task with the user data that was entered as properties in a task form. */
void
submitTaskFormData
(
String
taskId
,
Map
<
String
,
String
>
properties
);
/** */
void
add
TaskComment
(
String
task
Id
,
String
message
);
/**
Add a comment to a task and/or process instance.
*/
void
add
Comment
(
String
taskId
,
String
processInstance
Id
,
String
message
);
/** The comments related to the given task. */
List
<
Comment
>
getTaskComments
(
String
taskId
);
/** The comments related to the given process instance. */
List
<
Comment
>
getProcessInstanceComments
(
String
processInstanceId
);
}
modules/activiti-engine/src/main/java/org/activiti/engine/TaskService.java
浏览文件 @
c31849e5
...
...
@@ -64,6 +64,7 @@ public interface TaskService {
* Deletes the given task.
* @param taskId The id of the task that will be deleted, cannot be null. If no task
* exists with the given taskId, the operation is ignored.
* @param cascade If cascade is true, also the historic information related to this task is deleted.
*/
void
deleteTask
(
String
taskId
,
boolean
cascade
);
...
...
@@ -71,6 +72,7 @@ public interface TaskService {
* Deletes all tasks of the given collection.
* @param taskIds The id's of the tasks that will be deleted, cannot be null. All
* id's in the list that don't have an existing task will be ignored.
* @param cascade If cascade is true, also the historic information related to this task is deleted.
*/
void
deleteTasks
(
Collection
<
String
>
taskIds
,
boolean
cascade
);
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/form/Comment.java
浏览文件 @
c31849e5
...
...
@@ -13,6 +13,8 @@
package
org.activiti.engine.form
;
import
java.util.Date
;
/**
* @author Tom Baeyens
...
...
@@ -20,5 +22,8 @@ package org.activiti.engine.form;
public
interface
Comment
{
String
getUserId
();
Date
getTime
();
String
getTaskId
();
String
getProcessInstanceId
();
String
getMessage
();
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/FormServiceImpl.java
浏览文件 @
c31849e5
...
...
@@ -20,9 +20,12 @@ import org.activiti.engine.FormService;
import
org.activiti.engine.form.Comment
;
import
org.activiti.engine.form.StartFormData
;
import
org.activiti.engine.form.TaskFormData
;
import
org.activiti.engine.impl.cmd.AddCommentCmd
;
import
org.activiti.engine.impl.cmd.GetProcessInstanceCommentsCmd
;
import
org.activiti.engine.impl.cmd.GetRenderedStartFormCmd
;
import
org.activiti.engine.impl.cmd.GetRenderedTaskFormCmd
;
import
org.activiti.engine.impl.cmd.GetStartFormCmd
;
import
org.activiti.engine.impl.cmd.GetTaskCommentsCmd
;
import
org.activiti.engine.impl.cmd.GetTaskFormCmd
;
import
org.activiti.engine.impl.cmd.SubmitStartFormCmd
;
import
org.activiti.engine.impl.cmd.SubmitTaskFormCmd
;
...
...
@@ -70,12 +73,15 @@ public class FormServiceImpl extends ServiceImpl implements FormService {
commandExecutor
.
execute
(
new
SubmitTaskFormCmd
(
taskId
,
properties
));
}
@Override
public
void
addTaskComment
(
String
taskId
,
String
message
)
{
public
void
addComment
(
String
taskId
,
String
processInstance
,
String
message
)
{
commandExecutor
.
execute
(
new
AddCommentCmd
(
taskId
,
processInstance
,
message
));
}
@Override
public
List
<
Comment
>
getTaskComments
(
String
taskId
)
{
return
null
;
return
commandExecutor
.
execute
(
new
GetTaskCommentsCmd
(
taskId
));
}
public
List
<
Comment
>
getProcessInstanceComments
(
String
processInstanceId
)
{
return
commandExecutor
.
execute
(
new
GetProcessInstanceCommentsCmd
(
processInstanceId
));
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/AddCommentCmd.java
0 → 100644
浏览文件 @
c31849e5
/* 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
org.activiti.engine.impl.form.CommentEntity
;
import
org.activiti.engine.impl.identity.Authentication
;
import
org.activiti.engine.impl.interceptor.Command
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.util.ClockUtil
;
/**
* @author Tom Baeyens
*/
public
class
AddCommentCmd
implements
Command
<
Object
>
{
protected
String
taskId
;
protected
String
processInstanceId
;
protected
String
message
;
public
AddCommentCmd
(
String
taskId
,
String
processInstanceId
,
String
message
)
{
this
.
taskId
=
taskId
;
this
.
processInstanceId
=
processInstanceId
;
this
.
message
=
message
;
}
public
Object
execute
(
CommandContext
commandContext
)
{
String
userId
=
Authentication
.
getAuthenticatedUserId
();
CommentEntity
comment
=
new
CommentEntity
();
comment
.
setUserId
(
userId
);
comment
.
setTime
(
ClockUtil
.
getCurrentTime
());
comment
.
setTaskId
(
taskId
);
comment
.
setProcessInstanceId
(
processInstanceId
);
comment
.
setMessage
(
message
);
commandContext
.
getDbSqlSession
()
.
insert
(
comment
);
return
null
;
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteTaskCmd.java
浏览文件 @
c31849e5
...
...
@@ -81,6 +81,9 @@ public class DeleteTaskCmd implements Command<Void> {
dbSqlSession
.
delete
(
HistoricDetailEntity
.
class
,
historicTaskDetail
.
getId
());
}
}
if
(
historyLevel
>=
ProcessEngineConfigurationImpl
.
HISTORYLEVEL_ACTIVITY
)
{
dbSqlSession
.
delete
(
"deleteCommentsByTaskId"
,
taskId
);
}
}
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetProcessInstanceCommentsCmd.java
0 → 100644
浏览文件 @
c31849e5
/* 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.form.Comment
;
import
org.activiti.engine.impl.interceptor.Command
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
/**
* @author Tom Baeyens
*/
public
class
GetProcessInstanceCommentsCmd
implements
Command
<
List
<
Comment
>>
{
protected
String
processInstanceId
;
public
GetProcessInstanceCommentsCmd
(
String
processInstanceId
)
{
this
.
processInstanceId
=
processInstanceId
;
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
Comment
>
execute
(
CommandContext
commandContext
)
{
return
commandContext
.
getDbSqlSession
()
.
getSqlSession
()
.
selectList
(
"selectCommentsByProcessInstanceId"
,
processInstanceId
);
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetTaskCommentsCmd.java
0 → 100644
浏览文件 @
c31849e5
/* 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.form.Comment
;
import
org.activiti.engine.impl.interceptor.Command
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
/**
* @author Tom Baeyens
*/
public
class
GetTaskCommentsCmd
implements
Command
<
List
<
Comment
>>
{
protected
String
taskId
;
public
GetTaskCommentsCmd
(
String
taskId
)
{
this
.
taskId
=
taskId
;
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
Comment
>
execute
(
CommandContext
commandContext
)
{
return
commandContext
.
getDbSqlSession
()
.
getSqlSession
()
.
selectList
(
"selectCommentsByTaskId"
,
taskId
);
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/form/CommentEntity.java
0 → 100644
浏览文件 @
c31849e5
/* 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.form
;
import
java.util.Date
;
import
org.activiti.engine.form.Comment
;
import
org.activiti.engine.impl.db.PersistentObject
;
/**
* @author Tom Baeyens
*/
public
class
CommentEntity
implements
Comment
,
PersistentObject
{
protected
String
id
;
protected
String
userId
;
protected
Date
time
;
protected
String
taskId
;
protected
String
processInstanceId
;
protected
String
message
;
public
Object
getPersistentState
()
{
return
CommentEntity
.
class
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
}
public
String
getTaskId
()
{
return
taskId
;
}
public
void
setTaskId
(
String
taskId
)
{
this
.
taskId
=
taskId
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
Date
getTime
()
{
return
time
;
}
public
void
setTime
(
Date
time
)
{
this
.
time
=
time
;
}
public
String
getProcessInstanceId
()
{
return
processInstanceId
;
}
public
void
setProcessInstanceId
(
String
processInstanceId
)
{
this
.
processInstanceId
=
processInstanceId
;
}
}
modules/activiti-engine/src/main/resources/org/activiti/db/ibatis/history.mapping.xml
浏览文件 @
c31849e5
...
...
@@ -612,4 +612,46 @@
</where>
</sql>
<!-- COMMENT INSERT -->
<insert
id=
"insertComment"
parameterType=
"org.activiti.engine.impl.form.CommentEntity"
>
insert into ACT_HI_DETAIL (ID_, TYPE_, NAME_, TIME_, TASK_ID_, PROC_INST_ID_, TEXT_)
values (
#{id ,jdbcType=VARCHAR},
'comment',
#{userId ,jdbcType=VARCHAR},
#{time ,jdbcType=TIMESTAMP},
#{taskId ,jdbcType=VARCHAR},
#{processInstanceId ,jdbcType=VARCHAR},
#{message ,jdbcType=VARCHAR}
)
</insert>
<!-- COMMENT DELETE -->
<delete
id=
"deleteCommentsByTaskId"
parameterType=
"string"
>
delete from ACT_HI_DETAIL where TASK_ID_ = #{taskId}
</delete>
<!-- COMMENT RESULTMAP -->
<resultMap
id=
"commentResultMap"
type=
"org.activiti.engine.impl.form.CommentEntity"
>
<id
property=
"id"
column=
"ID_"
jdbcType=
"VARCHAR"
/>
<result
property=
"userId"
column=
"NAME_"
jdbcType=
"VARCHAR"
/>
<result
property=
"time"
column=
"TIME_"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"taskId"
column=
"TASK_ID_"
jdbcType=
"VARCHAR"
/>
<result
property=
"processInstanceId"
column=
"PROC_INST_ID_"
jdbcType=
"VARCHAR"
/>
<result
property=
"message"
column=
"TEXT_"
jdbcType=
"VARCHAR"
/>
</resultMap>
<!-- COMMENT SELECT -->
<select
id=
"selectCommentsByTaskId"
parameterType=
"string"
resultMap=
"commentResultMap"
>
select * from ACT_HI_DETAIL where TASK_ID_ = #{taskId,jdbcType=VARCHAR}
</select>
<select
id=
"selectCommentsByProcessInstanceId"
parameterType=
"string"
resultMap=
"commentResultMap"
>
select * from ACT_HI_DETAIL where PROC_INST_ID_ = #{processInstanceId,jdbcType=VARCHAR}
</select>
</mapper>
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.h2.upgradestep.53.to.54.identity.sql
浏览文件 @
c31849e5
...
...
@@ -8,6 +8,7 @@ create table ACT_ID_INFO (
TYPE_
varchar
(
64
),
KEY_
varchar
(
255
),
VALUE_
varchar
(
255
),
PASSWORD_
varchar
(
255
),
PASSWORD_
longvarbinary
,
PARENT_ID_
varchar
(
255
),
primary
key
(
ID_
)
);
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/task/TaskServiceTest.java
浏览文件 @
c31849e5
...
...
@@ -17,10 +17,13 @@ import java.util.Arrays;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.engine.form.Comment
;
import
org.activiti.engine.identity.Group
;
import
org.activiti.engine.identity.User
;
import
org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl
;
...
...
@@ -28,8 +31,8 @@ import org.activiti.engine.impl.test.PluggableActivitiTestCase;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.task.DelegationState
;
import
org.activiti.engine.task.IdentityLink
;
import
org.activiti.engine.task.Task
;
import
org.activiti.engine.task.IdentityLinkType
;
import
org.activiti.engine.task.Task
;
import
org.activiti.engine.test.Deployment
;
/**
...
...
@@ -90,6 +93,40 @@ public class TaskServiceTest extends PluggableActivitiTestCase {
taskService
.
deleteTask
(
task
.
getId
(),
true
);
}
public
void
testTaskComments
()
{
Task
task
=
taskService
.
newTask
();
task
.
setOwner
(
"johndoe"
);
taskService
.
saveTask
(
task
);
String
taskId
=
task
.
getId
();
identityService
.
setAuthenticatedUserId
(
"johndoe"
);
// Fetch the task again and update
formService
.
addComment
(
taskId
,
null
,
"look at this"
);
Comment
comment
=
formService
.
getTaskComments
(
taskId
).
get
(
0
);
assertEquals
(
"johndoe"
,
comment
.
getUserId
());
assertEquals
(
taskId
,
comment
.
getTaskId
());
assertNull
(
comment
.
getProcessInstanceId
());
assertEquals
(
"look at this"
,
comment
.
getMessage
());
assertNotNull
(
comment
.
getTime
());
formService
.
addComment
(
taskId
,
"pid"
,
"one"
);
formService
.
addComment
(
taskId
,
"pid"
,
"two"
);
Set
<
String
>
expectedComments
=
new
HashSet
<
String
>();
expectedComments
.
add
(
"one"
);
expectedComments
.
add
(
"two"
);
Set
<
String
>
comments
=
new
HashSet
<
String
>();
for
(
Comment
cmt:
formService
.
getProcessInstanceComments
(
"pid"
))
{
comments
.
add
(
cmt
.
getMessage
());
}
assertEquals
(
expectedComments
,
comments
);
// Finally, delete task
taskService
.
deleteTask
(
taskId
,
true
);
}
public
void
testTaskDelegation
()
{
Task
task
=
taskService
.
newTask
();
task
.
setOwner
(
"johndoe"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录