Expand my Community achievements bar.

SOLVED

Determine Workflow is complete Programmatically

Avatar

Level 10

All,

Is there a way to determine programmatically on when the workflow is complete so that i could do something, say clear an arraylist, once it is complete?

Regards,

Nicole

1 Accepted Solution

Avatar

Correct answer by
Level 10

You know the payload. Adopt it to WorkflowStatus. Then from WorkflowStatus can find it is completed or not. 

http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/workflow/status/WorkflowStatus.html

View solution in original post

4 Replies

Avatar

Level 8

I suppose you could use this to find when the workflow was completed:

http://dev.day.com/docs/en/cq/current/javadoc/com/adobe/granite/workflow/exec/Workflow.html#getTimeE...

I'm not sure what it returns when it is not yet complete (hopefully null or "")

 

scott

Avatar

Level 10

What is exact use case?   Why can;t you do clean up as last step in your workflow.

Avatar

Level 10

My Use case is on rollout trigger a workflow, which picks the payload paths as chapters, one specifies while creating a livecopy.

Now on Initial rollout, i managed to generate an xliff by getting each payload path in the execute method(multiple calls for execute method) putting the payload paths in an arraylist, and then calling the Query Builder rest service to retrieve the nodes with required resourceTypes.

Now when i try to create a livecopy2, selecting chapters, my arraylist gets appended with old values plus the recent. I want to clear the arraylist probably on workflow complete.

Please let me know.

 

public void execute(WorkItem item, WorkflowSession session, MetaDataMap args)
            throws WorkflowException {
        // TODO Auto-generated method stub
        WorkflowData workflowData = item.getWorkflowData();
        System.out.println(workflowData.getPayload().toString());
        String path = workflowData.getPayload().toString();
        arrList.add(path);    // Arraylist that i would like to clear once workflow is complete.

generateXLIFF -> method that accepts arrList as parameter. -> 

}

Avatar

Correct answer by
Level 10

You know the payload. Adopt it to WorkflowStatus. Then from WorkflowStatus can find it is completed or not. 

http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/workflow/status/WorkflowStatus.html