cancel
Showing results for 
Search instead for 
Did you mean: 

Starting a workflow in a pool (Java) [SOLVED]

jimcornmell
Champ in-the-making
Champ in-the-making
Hi All,

Below is part of some code I'm generating to start a workflow task in Java.  The problem I'm having is starting the task in a pool, rather than a user.  If anyone can let me know how to do this that would be great.

I've tried several things including setting the parameter WorkflowModel.ASSOC_ASSIGNEE to be the name of the pool, GROUP_NameOfPool.  But this does not work.  I've also tried setting ASSOC_POOLED_ACTORS but then the workflow does not start at all.

Appologies for the state of the code, it's not production quality yet.

Thanks in advance.

Jim

….
// Get a list of workflow definitions and search through them for the one we want.
// Not sure if this is the best way to do this, but it seems to work.
List<WorkflowDefinition> workflowDefs = workflowService.getDefinitions();
Iterator<WorkflowDefinition> workflowDefsIterator = workflowDefs.iterator();
WorkflowDefinition workflowDef = null;

// Get a handle to the required workflow.
while (workflowDefsIterator.hasNext()) {
   workflowDef = workflowDefsIterator.next();

   if (workflowDef.name.equals(JBPM_WORKFLOW_NAME)) {
      break;
   }
}

// If we did not find the workflow error.
if (!workflowDef.name.equals(JBPM_WORKFLOW_NAME)) {
   return;
}

// Add the files to the workflow.
// First create the workflow, passing a null since this seems to be the most appropriate.
NodeRef workflowNodeRef = workflowService.createPackage(null);

for (int x = 0; x < fileList.length; x++) {
   nodeService.addChild(workflowNodeRef, fileRefs[x], ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "Advert within the workflow package"));
}

// Finally kick the workflow off.
Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowNodeRef);
parameters.put(WorkflowModel.ASSOC_ASSIGNEE, "GROUP_NameOfPool");
parameters.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, new Date(System.currentTimeMillis() + DUE_HOURS.getTime()));
parameters.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "Name of task");
WorkflowPath path = workflowService.startWorkflow(workflowDef.id, parameters);
….
6 REPLIES 6

rgouyet
Champ in-the-making
Champ in-the-making
Hi,

I'm not expert in workflows but do your workflow model reflect the use of pool ?

Abstract  from Jeff Potts : http://ecmarchitect.com/archives/2007/11/19/785

<swimlane name="marketing">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<pooledactors>#{people.getGroup('GROUP_marketing')}</pooledactors>
</assignment>
</swimlane>

RG

jimcornmell
Champ in-the-making
Champ in-the-making
Hi,

Yep.  Below is a hacked version of my workflow.  One the job is assigned I can login as the user who has it.  I can then pass it to the next pool OK.  It just the initial commencement of the task which starts with the user who started it, not the pool.

Jim

<?xml version="1.0" encoding="UTF-8"?>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="mywf:my_workflow">

   <!– ======================================================================= –>
   <!– Swimlanes for the different users the user may touch. –>
   <swimlane name="readers">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <pooledactors>
            #{people.getGroup('GROUP_NameOfPool')}
         </pooledactors>
      </assignment>
   </swimlane>

   <swimlane name="artists">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <pooledactors>
            #{people.getGroup('GROUP_NameOfOtherPool')}
         </pooledactors>
      </assignment>
   </swimlane>

   <swimlane name="initiator">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <pooledactors>
            #{people.getGroup('GROUP_NameOfYetOtherPool')}
         </pooledactors>
      </assignment>
   </swimlane>

   <!– ======================================================================= –>
   <!– States the job goes through. –>
   <start-state name="Start">
      <task name="mywf:createTask" swimlane="artists"/>
      <transition name="Send To Reader" to="Reading"></transition>
   </start-state>

   <task-node name="Reading">
      <task name="mywf:readingTask" swimlane="readers"/>
      <transition name="Finished Job" to="Approved"></transition>
      <transition name="Send To Artist For Amend" to="Amend"></transition>
   </task-node>

   <task-node name="Amend">
      <task name="mywf:amendTask" swimlane="artists"/>
      <transition name="Return To Reader" to="Reading"></transition>
   </task-node>

   <end-state name="Approved" />

   <event type="process-end">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            logger.log("End of process. Cancelled: " + cancelled);
         </script>
      </action>
   </event>

   <!– ======================================================================= –>
</process-definition>

jimcornmell
Champ in-the-making
Champ in-the-making
Hi,

Has anyone come accross the issue above?  Please help!

Jim

jimcornmell
Champ in-the-making
Champ in-the-making

jaime
Champ in-the-making
Champ in-the-making
hello,
I have a question for your code,
How do you implement the interface Workflowservice?the class that you use is…
thank.

jaime
Champ in-the-making
Champ in-the-making
Hello again,jeje
Do you write all your code???
bye.