01-14-2015 09:59 PM
01-14-2015 10:09 PM
01-16-2015 06:46 AM
01-20-2015 02:23 AM
01-21-2015 03:08 AM
01-21-2015 04:34 AM
01-21-2015 08:56 AM
05-30-2016 08:50 PM
05-31-2016 02:38 AM
would you have an example of how to write a custom Command and use it for the above use case?
public void setExecutionToActivity(String executionId, String activityId) {
ProcessEngineConfigurationImpl processEngineConfiguration = …..
processEngineConfiguration.getCommandExecutor().execute(new SetActivityCmd(executionId, activityId));
}
….
private static class SetActivityCmd implements Command<Void> {
private final String executionId;
private final String activityId;
private SetActivityCmd(String executionId, String activityId) {
this.executionId = executionId;
this.activityId = activityId;
}
@Override
public Void execute(CommandContext commandContext) {
ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(this.executionId);
execution.setActivity(new ActivityImpl(this.activityId, execution.getProcessDefinition()));
return null;
}
}
/**
* Delete an existing runtime process instance.
*
* @param processInstanceId
* id of process instance to delete, cannot be null.
* @param deleteReason
* reason for deleting, can be null.
* @throws ActivitiObjectNotFoundException
* when no process instance is found with the given id.
*/
void deleteProcessInstance(String processInstanceId, String deleteReason);
02-01-2017 06:34 AM
Hi,
I'm trying to use your code to skip a task in a process. For example, I have a process start-->userTask1-->userTask2-->userTask3-->end, so I'm checking if I completed userTask1 and after I'm using the command executor as you described above to jump to userTask3, skipping userTask2.
The thing is that whenever I execute the command I get the following error:
[main] ERROR org.activiti.engine.impl.interceptor.CommandContext - Error while closing command context
java.lang.NullPointerException
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.signal(ExecutionEntity.java:414)
at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:203)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:52)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:59)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:178)
at com.example.OnboardingRequest.main(OnboardingRequest.java:59)
I also downloaded the unit test on your github, but when I'm trying to transpose your code into mine, I get the same error.
Have you some ideas why is this happening? Probably I'm making some silly mistake because I'm a beginner with Activiti.
Thank you in advance.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.