Determine Workflow is complete Programmatically | Community
Skip to main content
Level 9
October 16, 2015
Solved

Determine Workflow is complete Programmatically

  • October 16, 2015
  • 4 replies
  • 1208 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sham_HC

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

4 replies

Scott_Brodersen
Level 8
October 16, 2015

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#getTimeEnded()

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

 

scott

Sham_HC
Level 10
October 16, 2015

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

Level 9
October 16, 2015

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. -> 

}

Sham_HC
Sham_HCAccepted solution
Level 10
October 16, 2015

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