Hi all

I'm trying to remove task on server, here is the API

public static void destroyPendingTasksByProcessContext(String processKey) throws EnvironmentNotAvailableException, PersistencyException, Exception{
        SecurityManagerFactory.getSecurityManager().executeAsSystem(() -> {
            TaskQuery taskQuery = TaskQuery.create()
              .where().customVarCharField5().isEqual(processKey);
            List<ITask> tasks = Ivy.wf().getTaskQueryExecutor().getResults(taskQuery);
            tasks.forEach(destroyTask -> {
                destroyTask.destroy();
            });
            return StringUtils.EMPTY;
        });
    }

in the query you can see i use a processkey as a flag to destroy all tasks which are related to my project. And i got this exception:

Caused by: java.lang.IllegalStateException: State of Task must be one of the following values DELAYED, SUSPENDED, PARKED, RESUMED, UNASSIGNED, FAILED, READY_FOR_JOIN, JOINING, JOIN_FAILED, CREATED, WAITING_FOR_INTERMEDIATE_EVENT but is DONE (The task might have been finished by another user.)

How can we solve it? Thanks

asked 16.12.2016 at 03:49

trungdv's gravatar image

trungdv
(suspended)
accept rate: 52%


It’s not possible to destroy a task in state DONE.

A Task in state DONE or DESTROYED implies that the task has been finished. The state DONE implies a normal ending, the state DESTROYED an abnormal ending (performed by a user / API call). As the state diagram below shows, both are ending states.

Task States

Btw, when you try to delete a Task/Case physically from the DB the answer how-to-cleanup-old-cases-tasks could help.

link

answered 16.12.2016 at 11:46

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦
(suspended)
accept rate: 75%

hi @Flavio Sadeghi ♦♦

Another question, can we change task state from RUNNING state to DELAYED programmatically? i see ivy does not expose function to set state, it may break this diagram if we expose api, right?

(12.05.2017 at 04:31) trungdv trungdv's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×13

Asked: 16.12.2016 at 03:49

Seen: 2,598 times

Last updated: 12.05.2017 at 04:31