cancel
Showing results for 
Search instead for 
Did you mean: 

Explanations about WorkflowService and related classes

amenel
Champ in-the-making
Champ in-the-making
Hi all,
I an currently trying to integrate workflows into some Java piece of software we wrote that uses Alfresco. I have little general knowledge about workflows so I am targeting the well-informed people around here. All classes I refer to are in org.alfresco.service.cmr.workflow

In WorkflowService, function startWorkflow takes a workflow definition id and parameters to initialize the properties of the start task. It returns a WorkflowPath object that has a WorkflowInstance and a WorkflowNode. The WorkflowInstance object has two objects workflowPackage and context, both as NodeRef.

- If I start an advanced workflow from a content's properties page, is it correct to say that doing so created a workflow instance ?

- What is the meaning attached to WorkflowNode, workflowPackage and context ? I am trying to know whether one of these holds a reference to the content I started the workflow for.

- How can I determine (from the WorkflowPath object that's returned) which content the workflow instance I started is attached to ?

- How can I grab the taskId for the "start task" from the WorkflowPath object returned ? Is there even a taskId attached to a "start task" ? This question is motivated by the user actions I plan to have later (one button per possible transition), which will only require using "updateTask" (to save properties) and "endTask" (to follow transitions).
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
Have you looked at this page? http://wiki.alfresco.com/wiki/Workflow_Reqs_and_Design#Workflow_APIs.
- If I start an advanced workflow from a content's properties page, is it correct to say that doing so created a workflow instance ?
Yes.

- What is the meaning attached to WorkflowNode, workflowPackage and context ? I am trying to know whether one of these holds a reference to the content I started the workflow for.
WorkflowNode - a node within a workflow definition.
Workflow package contains the data that the workflow operates upon.    

- How can I determine (from the WorkflowPath object that's returned) which content the workflow instance I started is attached to ?
instance.workflowPackage()

- How can I grab the taskId for the "start task" from the WorkflowPath object returned ? Is there even a taskId attached to a "start task" ? This question is motivated by the user actions I plan to have later (one button per possible transition), which will only require using "updateTask" (to save properties) and "endTask" (to follow transitions).
Yes there is a taskId

amenel
Champ in-the-making
Champ in-the-making
No, I hadn't read that page. Always search all sources before asking… I should have remembered that.
Valuable information in there, thank you for pointing it and for your reply.

amenel
Champ in-the-making
Champ in-the-making
Hi all,
I am coming back here for what I think is the last thing that's not quite clear yet about workflows: how packages are treated.

I am specifically interested in creating a package and attaching (programmatically) an existing content to an already started workflow instance. I guess that, when calling updateTask, I can use params.put(WorkflowModel.ASSOC_PACKAGE, myPackage) to specify the folder I want as package. But, how can I "add" a content to the package while not moving (or cloning) that content from its current location to under my package folder ? To put it differently, I do not want to use a ContentModel.ASSOC_CONTAINS association between the package folder and the pre-existing content, which I think will fail anyway. Or else, what type of association should I create between the package and the content to have that content returned by WorkflowService.getPackageContents  and the workflow returned by WorkflowService.getWorkflowsForContent ?

Other question, when I use WorkflowService.createPackage(null), is there a default location for the package just created ? If yes, what is it ? and if no, what happens then ?

Any insights into this subject will be appreciated. Thanks.

amenel
Champ in-the-making
Champ in-the-making
But, how can I "add" a content to the package while not moving (or cloning) that content from its current location to under my package folder ? To put it differently, I do not want to use a ContentModel.ASSOC_CONTAINS association between the package folder and the pre-existing content, which I think will fail anyway.
This was a wrong assumption of mine. Even when using ContentModel.ASSOC_CONTAINS, the content remains in its parent folder while still being associated with the workflow instance.

Other question, when I use WorkflowService.createPackage(null), is there a default location for the package just created ? If yes, what is it ? and if no, what happens then ?

The package is created under what seems to be a system folder. Use NodeService.getPath on the node ref to get it.