Skip to main content
Level 9
Oct 16, 2015 2:27 AM UTC
Solved

Determine Workflow is complete Programmatically

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.
Sham_HC
Sham_HCAccepted solution
Level 10
Oct 16, 2015 2:27 AM UTC

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

Sham_HC
Sham_HCAccepted solution
Level 10
Oct 16, 2015 2:27 AM UTC

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

Translate
Level 9
Oct 16, 2015 2:27 AM UTC

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

}

Translate
Sham_HC
Level 10
Oct 16, 2015 2:27 AM UTC

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

Translate
Scott_Brodersen
Level 8
Oct 16, 2015 2:27 AM UTC

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

Translate