本文整理汇总了Java中org.activiti.engine.task.Comment类的典型用法代码示例。如果您正苦于以下问题:Java Comment类的具体用法?Java Comment怎么用?Java Comment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Comment类属于org.activiti.engine.task包,在下文中一共展示了Comment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@Override
public void delete(PersistentObject persistentObject) {
checkHistoryEnabled();
super.delete(persistentObject);
Comment comment = (Comment) persistentObject;
if (getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
// Forced to fetch the process-instance to associate the right process definition
String processDefinitionId = null;
String processInstanceId = comment.getProcessInstanceId();
if (comment.getProcessInstanceId() != null) {
ExecutionEntity process = getProcessInstanceManager().findExecutionById(comment.getProcessInstanceId());
if (process != null) {
processDefinitionId = process.getProcessDefinitionId();
}
}
getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_DELETED, persistentObject, processInstanceId, processInstanceId, processDefinitionId));
}
}
示例2: insert
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@Override
public void insert(PersistentObject persistentObject) {
checkHistoryEnabled();
super.insert(persistentObject);
Comment comment = (Comment) persistentObject;
if (getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
// Forced to fetch the process-instance to associate the right process definition
String processDefinitionId = null;
String processInstanceId = comment.getProcessInstanceId();
if (comment.getProcessInstanceId() != null) {
ExecutionEntity process = getProcessInstanceManager().findExecutionById(comment.getProcessInstanceId());
if (process != null) {
processDefinitionId = process.getProcessDefinitionId();
}
}
getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, persistentObject, processInstanceId, processInstanceId, processDefinitionId));
getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_INITIALIZED, persistentObject, processInstanceId, processInstanceId, processDefinitionId));
}
}
示例3: createComment
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@POST
@Path("/{processInstanceId}/comments")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public Response createComment(@PathParam("processInstanceId") String processInstanceId, CommentResponse comment) {
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
if (comment.getMessage() == null) {
throw new ActivitiIllegalArgumentException("Comment text is required.");
}
TaskService taskService = BPMNOSGIService.getTaskService();
Comment createdComment = taskService.addComment(null, instance.getId(), comment.getMessage());
CommentResponse commentResponse = new RestResponseFactory().createRestComment(createdComment, uriInfo
.getBaseUri().toString());
return Response.ok().status(Response.Status.CREATED).entity(commentResponse).build();
}
示例4: getComment
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@GET
@Path("/{processInstanceId}/comments/{commentId}")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public Response getComment(@PathParam("processInstanceId") String processInstanceId,
@PathParam("commentId") String commentId) {
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
TaskService taskService = BPMNOSGIService.getTaskService();
Comment comment = taskService.getComment(commentId);
if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) {
throw new ActivitiObjectNotFoundException("Process instance '" + instance.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class);
}
CommentResponse commentResponse = new RestResponseFactory().createRestComment(comment, uriInfo.getBaseUri().toString());
return Response.ok().entity(commentResponse).build();
}
示例5: deleteComment
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@DELETE
@Path("/{processInstanceId}/comments/{commentId}")
public Response deleteComment(@PathParam("processInstanceId") String processInstanceId,
@PathParam("commentId") String commentId) {
TaskService taskService = BPMNOSGIService.getTaskService();
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
Comment comment = taskService.getComment(commentId);
if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) {
throw new ActivitiObjectNotFoundException("Process instance '" + instance.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class);
}
taskService.deleteComment(commentId);
return Response.ok().status(Response.Status.NO_CONTENT).build();
}
示例6: testAddCommentToProcessInstance
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@Deployment
public void testAddCommentToProcessInstance() {
if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcessInstanceComment");
taskService.addComment(null, processInstance.getId(), "Hello World");
List<Comment> comments = taskService.getProcessInstanceComments(processInstance.getId());
assertEquals(1, comments.size());
// Suspend process instance
runtimeService.suspendProcessInstanceById(processInstance.getId());
try {
taskService.addComment(null, processInstance.getId(), "Hello World 2");
} catch (ActivitiException e) {
assertTextPresent("Cannot add a comment to a suspended execution", e.getMessage());
}
// Delete comments again
taskService.deleteComments(null, processInstance.getId());
}
}
示例7: testTaskComments
import org.activiti.engine.task.Comment; //导入依赖的package包/类
public void testTaskComments() {
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
Task task = taskService.newTask();
task.setOwner("johndoe");
taskService.saveTask(task);
String taskId = task.getId();
identityService.setAuthenticatedUserId("johndoe");
// Fetch the task again and update
taskService.addComment(taskId, null, "look at this \n isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg kajsh dfuieqpgkja rzvkfnjviuqerhogiuvysbegkjz lkhf ais liasduh flaisduh ajiasudh vaisudhv nsfd");
Comment comment = taskService.getTaskComments(taskId).get(0);
assertEquals("johndoe", comment.getUserId());
assertEquals(taskId, comment.getTaskId());
assertNull(comment.getProcessInstanceId());
assertEquals("look at this isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg ...", ((Event)comment).getMessage());
assertEquals("look at this \n isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg kajsh dfuieqpgkja rzvkfnjviuqerhogiuvysbegkjz lkhf ais liasduh flaisduh ajiasudh vaisudhv nsfd", comment.getFullMessage());
assertNotNull(comment.getTime());
// Finally, delete task
taskService.deleteTask(taskId, true);
}
}
示例8: execute
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@Override
public Comment execute(CommandContext commandContext) {
for (TaskEntity taskEntity : Context.getCommandContext().getTaskEntityManager().findTasksByExecutionId(executionId)) {
Context.getCommandContext().getTaskEntityManager().deleteTask(taskEntity, "jump", false);
}
ExecutionEntity executionEntity = Context.getCommandContext().getExecutionEntityManager().findExecutionById(executionId);
ProcessDefinitionImpl processDefinition = executionEntity.getProcessDefinition();
ActivityImpl activity = processDefinition.findActivity(activityId);
executionEntity.executeActivity(activity);
return null;
}
示例9: index
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@RequestMapping("")
@PermessionType
public String index(HttpServletRequest request, HttpSession session, Model model){
// 开发任务列表
List<DevTask> devTaskList = devTaskService.getByUserId(super.getLoginIdentity().getUserId());
model.addAttribute("devTaskList", devTaskList);
// 流程任务
List<Task> taskAll = activitiService.queryTask(String.valueOf(super.getLoginIdentity().getUserId()));
if (CollectionUtils.isNotEmpty(taskAll)) {
for (DevTaskDefinitionKey item : AvtivitiDic.DevTaskDefinitionKey.values()) {
List<Task> temp = new ArrayList<Task>();
for (Task task : taskAll) {
if (item.name().equals(task.getTaskDefinitionKey())) {
temp.add(task);
}
}
model.addAttribute(item.name(), temp);
}
// 任务1-批注列表
List<Comment> CommentList = activitiService.getProcessInstanceComments(taskAll.get(0).getProcessInstanceId());
if (CollectionUtils.isNotEmpty(CommentList)) {
for (Comment comment : CommentList) {
logger.info("time:{}, userId:{}, msg:{}, toString:{}",
new Object[]{comment.getTime(), comment.getUserId(), comment.getFullMessage(), comment.toString()});
}
}
}
return "front/task/index";
}
示例10: findCommentsByTaskIdAndType
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public List<Comment> findCommentsByTaskIdAndType(String taskId, String type) {
checkHistoryEnabled();
Map<String, Object> params = new HashMap<>();
params.put("taskId", taskId);
params.put("type", type);
return getDbSqlSession().selectListWithRawParameter("selectCommentsByTaskIdAndType", params, 0, Integer.MAX_VALUE);
}
示例11: findCommentsByProcessInstanceId
import org.activiti.engine.task.Comment; //导入依赖的package包/类
public List<Comment> findCommentsByProcessInstanceId(String processInstanceId, String type) {
checkHistoryEnabled();
Map<String, Object> params = new HashMap<>();
params.put("processInstanceId", processInstanceId);
params.put("type", type);
return getDbSqlSession().selectListWithRawParameter("selectCommentsByProcessInstanceIdAndType", params, 0, Integer.MAX_VALUE);
}
示例12: execute
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public List<Comment> execute(CommandContext commandContext) {
if (StringUtils.isNotBlank(type)) {
List<Comment> commentsByProcessInstanceId = commandContext
.getCommentEntityManager()
.findCommentsByProcessInstanceId(processInstanceId, type);
return commentsByProcessInstanceId;
} else {
return commandContext
.getCommentEntityManager()
.findCommentsByProcessInstanceId(processInstanceId);
}
}
示例13: testTaskComments
import org.activiti.engine.task.Comment; //导入依赖的package包/类
public void testTaskComments() {
int historyLevel = processEngineConfiguration.getHistoryLevel();
if (historyLevel>ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
Task task = taskService.newTask();
task.setOwner("johndoe");
taskService.saveTask(task);
String taskId = task.getId();
identityService.setAuthenticatedUserId("johndoe");
// Fetch the task again and update
taskService.addComment(taskId, null, "look at this \n isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg kajsh dfuieqpgkja rzvkfnjviuqerhogiuvysbegkjz lkhf ais liasduh flaisduh ajiasudh vaisudhv nsfd");
Comment comment = taskService.getTaskComments(taskId).get(0);
assertEquals("johndoe", comment.getUserId());
assertEquals(taskId, comment.getTaskId());
assertNull(comment.getProcessInstanceId());
assertEquals("look at this isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg ...", ((Event)comment).getMessage());
assertEquals("look at this \n isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg kajsh dfuieqpgkja rzvkfnjviuqerhogiuvysbegkjz lkhf ais liasduh flaisduh ajiasudh vaisudhv nsfd", comment.getFullMessage());
assertNotNull(comment.getTime());
taskService.addComment(taskId, "pid", "one");
taskService.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: taskService.getProcessInstanceComments("pid")) {
comments.add(cmt.getFullMessage());
}
assertEquals(expectedComments, comments);
// Finally, delete task
taskService.deleteTask(taskId, true);
}
}
示例14: testNewUserProcess
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@Test
public void testNewUserProcess() throws InvocationTargetException, IllegalAccessException {
identityService.setAuthenticatedUserId("fozzie");
Map<String, Object> processVariables = Maps.newHashMap();
processVariables.put("approved", Boolean.FALSE);
UserForm userForm = new UserForm("newUser324", "pwabcdedfgss", "[email protected]", "jim", "smith", "engineering");
Set<ConstraintViolation<UserForm>> violations = validator.validate(userForm);
assertTrue(violations.size() == 0);
log.debug(violations.size());
processVariables.put("userForm", userForm);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("newChromeUser", processVariables);
Task task = taskService.createTaskQuery().taskCandidateGroup("admin").
//includeProcessVariables().
singleResult();
assertNotNull(task);
TaskForm taskForm = TaskForm.fromTask(task);
log.debug(taskForm);
List<Task> tasks = taskService.createTaskQuery().
taskCandidateOrAssigned("kermit").
orderByTaskCreateTime().asc().list();
log.debug("tasks size: " + tasks.size());
// assertTrue(tasks.size() == 1);
log.debug("owner: " + task.getOwner());
identityService.setAuthenticatedUserId("kermit");
taskService.setAssignee(task.getId(), "kermit");
taskService.addComment(task.getId(), pi.getId(), "Here is a comment");
List<Comment> comments = taskService.getTaskComments(task.getId());
assertTrue(comments.size() == 1);
log.debug(comments.get(0).getFullMessage());
log.debug(comments.get(0).getTime().toString());
Map<String, Object> taskVariables = new HashMap<String, Object>();
taskVariables.put("approved", true);
taskService.complete(task.getId(), taskVariables);
//HistoryService historyService.
}
示例15: testDocApprovalFlow
import org.activiti.engine.task.Comment; //导入依赖的package包/类
@Test
public void testDocApprovalFlow() throws InterruptedException {
setSpringSecurity("kermit");
Document doc = new Document();
doc.setGroupId("engineering");
doc.setCreatedDate(new Date());
doc.setTitle("title");
doc.setSummary("Summary");
doc.setContent("content");
doc.setAuthor("kermit");
String docId;
docId = documentService.createDocument(doc);
log.debug("new doc id: " + docId);
this.documentService.submitForApproval(docId);
setSpringSecurity("fozzie");
List<TaskForm> tasks = this.localTaskService.getTasks("fozzie");
assertTrue(tasks.size() == 1);
log.debug("got task: " + tasks.get(0).getName());
localTaskService.approveTask(true, "task approved blah blah blah", tasks.get(0).getId());
HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().
includeProcessVariables().processInstanceBusinessKey(docId).singleResult();
assertNotNull(pi);
log.debug("Duration time in millis: " + pi.getDurationInMillis());
List<HistoricTaskInstance> hTasks;
hTasks = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().processInstanceBusinessKey(docId).list();
assertTrue(hTasks.size() == 2);
HistoricTaskInstance approval = hTasks.get(1);
Map<String, Object> vars = approval.getTaskLocalVariables();
List<Comment> comments = taskService.getTaskComments(approval.getId());
}